* [RFT] convert syskonnect gigabit ether driver to PCI module interface
@ 2004-06-22 23:11 Stephen Hemminger
2004-06-22 23:23 ` Jeff Garzik
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2004-06-22 23:11 UTC (permalink / raw)
To: Mirko Lindner, Ralph Roesler; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 430 bytes --]
This patch converts the SysKonnect Gigabit Ethernet (Yukon) driver from
the old pci_find_class infrastructure, to the current 2.4/2.6 pci_module probing
model. The device identification is no longer done in the macro, but in a pci_device_id
table like other drivers.
I don't have any hardware to test it on, but it builds on 2.6; could someone please
validate that it correctly finds and initializes all the ports on the card.
[-- Attachment #2: skge-pci-ids.patch --]
[-- Type: text/plain, Size: 1804 bytes --]
diff -Nru a/include/linux/pci_ids.h b/include/linux/pci_ids.h
--- a/include/linux/pci_ids.h 2004-06-22 10:08:12 -07:00
+++ b/include/linux/pci_ids.h 2004-06-22 10:08:12 -07:00
@@ -967,12 +967,14 @@
#define PCI_VENDOR_ID_3COM 0x10b7
#define PCI_DEVICE_ID_3COM_3C985 0x0001
+#define PCI_DEVICE_ID_3COM_3C940 0x1700
#define PCI_DEVICE_ID_3COM_3C339 0x3390
#define PCI_DEVICE_ID_3COM_3C359 0x3590
#define PCI_DEVICE_ID_3COM_3C590 0x5900
#define PCI_DEVICE_ID_3COM_3C595TX 0x5950
#define PCI_DEVICE_ID_3COM_3C595T4 0x5951
#define PCI_DEVICE_ID_3COM_3C595MII 0x5952
+#define PCI_DEVICE_ID_3COM_3C940B 0x80eb
#define PCI_DEVICE_ID_3COM_3C900TPO 0x9000
#define PCI_DEVICE_ID_3COM_3C900COMBO 0x9001
#define PCI_DEVICE_ID_3COM_3C905TX 0x9050
@@ -1420,6 +1422,9 @@
#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476
#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478
+#define PCI_VENDOR_ID_DLINK 0x1186
+#define PCI_DEVICE_ID_DLINK_DGE510T 0x4c00
+
#define PCI_VENDOR_ID_ARTOP 0x1191
#define PCI_DEVICE_ID_ARTOP_ATP8400 0x0004
#define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005
@@ -1735,6 +1740,9 @@
#define PCI_VENDOR_ID_KAWASAKI 0x136b
#define PCI_DEVICE_ID_MCHIP_KL5A72002 0xff01
+#define PCI_VENDOR_ID_CNET 0x1371
+#define PCI_DEVICE_ID_CNET_GIGACARD 0x434e
+
#define PCI_VENDOR_ID_LMC 0x1376
#define PCI_DEVICE_ID_LMC_HSSI 0x0003
#define PCI_DEVICE_ID_LMC_DS3 0x0004
@@ -1918,6 +1926,10 @@
#define PCI_DEVICE_ID_FARSITE_T4U 0x0640
#define PCI_DEVICE_ID_FARSITE_TE1 0x1610
#define PCI_DEVICE_ID_FARSITE_TE1C 0x1612
+
+#define PCI_VENDOR_ID_LINKSYS 0x1737
+#define PCI_DEVICE_ID_LINKSYS_EG1032 0x1032
+#define PCI_DEVICE_ID_LINKSYS_EG1064 0x1064
#define PCI_VENDOR_ID_ALTIMA 0x173b
#define PCI_DEVICE_ID_ALTIMA_AC1000 0x03e8
[-- Attachment #3: skge-pci-init.patch --]
[-- Type: application/octet-stream, Size: 23226 bytes --]
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/06/22 15:57:48-07:00 shemminger@zqx3.pdx.osdl.net
# skge-2
#
# drivers/net/sk98lin/h/skdrv2nd.h
# 2004/06/22 15:56:10-07:00 shemminger@zqx3.pdx.osdl.net +1 -55
# Import patch skge-2
#
# ChangeSet
# 2004/06/22 15:53:11-07:00 shemminger@zqx3.pdx.osdl.net
# skge-pci
#
# drivers/net/sk98lin/skge.c
# 2004/06/22 11:12:17-07:00 shemminger@zqx3.pdx.osdl.net +270 -292
# Import patch skge-pci
#
diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h 2004-06-22 15:59:00 -07:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h 2004-06-22 15:59:00 -07:00
@@ -53,60 +53,6 @@
#include "h/skrlmt.h"
#include "h/skgedrv.h"
-#define SK_PCI_ISCOMPLIANT(result, pdev) { \
- result = SK_FALSE; /* default */ \
- /* 3Com (0x10b7) */ \
- if (pdev->vendor == 0x10b7) { \
- /* Gigabit Ethernet Adapter (0x1700) */ \
- if ((pdev->device == 0x1700) || \
- (pdev->device == 0x80eb)) { \
- result = SK_TRUE; \
- } \
- /* SysKonnect (0x1148) */ \
- } else if (pdev->vendor == 0x1148) { \
- /* SK-98xx Gigabit Ethernet Server Adapter (0x4300) */ \
- /* SK-98xx V2.0 Gigabit Ethernet Adapter (0x4320) */ \
- if ((pdev->device == 0x4300) || \
- (pdev->device == 0x4320)) { \
- result = SK_TRUE; \
- } \
- /* D-Link (0x1186) */ \
- } else if (pdev->vendor == 0x1186) { \
- /* Gigabit Ethernet Adapter (0x4c00) */ \
- if ((pdev->device == 0x4c00)) { \
- result = SK_TRUE; \
- } \
- /* Marvell (0x11ab) */ \
- } else if (pdev->vendor == 0x11ab) { \
- /* Gigabit Ethernet Adapter (0x4320) */ \
- /* Gigabit Ethernet Adapter (0x4360) */ \
- /* Gigabit Ethernet Adapter (0x4361) */ \
- /* Belkin (0x5005) */ \
- if ((pdev->device == 0x4320) || \
- (pdev->device == 0x4360) || \
- (pdev->device == 0x4361) || \
- (pdev->device == 0x5005)) { \
- result = SK_TRUE; \
- } \
- /* CNet (0x1371) */ \
- } else if (pdev->vendor == 0x1371) { \
- /* GigaCard Network Adapter (0x434e) */ \
- if ((pdev->device == 0x434e)) { \
- result = SK_TRUE; \
- } \
- /* Linksys (0x1737) */ \
- } else if (pdev->vendor == 0x1737) { \
- /* Gigabit Network Adapter (0x1032) */ \
- /* Gigabit Network Adapter (0x1064) */ \
- if ((pdev->device == 0x1032) || \
- (pdev->device == 0x1064)) { \
- result = SK_TRUE; \
- } \
- } else { \
- result = SK_FALSE; \
- } \
-}
-
extern SK_MBUF *SkDrvAllocRlmtMbuf(SK_AC*, SK_IOC, unsigned);
extern void SkDrvFreeRlmtMbuf(SK_AC*, SK_IOC, SK_MBUF*);
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c 2004-06-22 15:59:00 -07:00
+++ b/drivers/net/sk98lin/skge.c 2004-06-22 15:59:00 -07:00
@@ -257,26 +257,40 @@
/* global variables *********************************************************/
static const char *BootString = BOOT_STRING;
struct SK_NET_DEVICE *SkGeRootDev = NULL;
-static int probed __initdata = 0;
static SK_BOOL DoPrintInterfaceChange = SK_TRUE;
/* local variables **********************************************************/
static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
-
-#ifdef CONFIG_PROC_FS
-static struct proc_dir_entry *pSkRootDir;
-#endif
-
-
+#define SK_PCI_DEVICE(vend, dev) \
+ { PCI_DEVICE(vend, dev), \
+ .class = PCI_CLASS_NETWORK_ETHERNET << 8, \
+ .class_mask = 0xffff00, }
+
+static struct pci_device_id skge_pci_table[] = {
+ SK_PCI_DEVICE(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940),
+ SK_PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE),
+ SK_PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU),
+ SK_PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T),
+ SK_PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320),
+/* Don't handle Yukon2 cards at the moment */
+/* 12-feb-2004 ---- mlindner@syskonnect.de */
+// SK_PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361),
+ SK_PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005), /* Belkin (0x5005) */
+ SK_PCI_DEVICE(PCI_VENDOR_ID_CNET, PCI_DEVICE_ID_CNET_GIGACARD),
+ SK_PCI_DEVICE(PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LINKSYS_EG1032),
+ SK_PCI_DEVICE(PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LINKSYS_EG1064),
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, skge_pci_table);
/*****************************************************************************
*
- * skge_probe - find all SK-98xx adapters
+ * skge_init_one -- initialize one PCI board
*
* Description:
- * This function scans the PCI bus for SK-98xx adapters. Resources for
+ * This function initializes a SK-98xx adapter. Resources for
* each adapter are allocated and the adapter is brought into Init 1
* state.
*
@@ -284,13 +298,12 @@
* 0, if everything is ok
* !=0, on error
*/
-static int __init skge_probe (void)
+static int __devinit skge_init_one (struct pci_dev *pdev,
+ const struct pci_device_id *ent)
{
- int boards_found = 0;
- int vendor_flag = SK_FALSE;
+ static int boards_found = 0;
SK_AC *pAC;
DEV_NET *pNet = NULL;
- struct pci_dev *pdev = NULL;
struct SK_NET_DEVICE *dev = NULL;
SK_BOOL DeviceFound = SK_FALSE;
SK_BOOL BootStringCount = SK_FALSE;
@@ -299,257 +312,230 @@
struct proc_dir_entry *pProcFile;
#endif
- if (probed)
- return -ENODEV;
- probed++;
-
-
- while((pdev = pci_find_class(PCI_CLASS_NETWORK_ETHERNET << 8, pdev))) {
-
- if (pci_enable_device(pdev)) {
- continue;
- }
- dev = NULL;
- pNet = NULL;
-
- /* Don't handle Yukon2 cards at the moment */
- /* 12-feb-2004 ---- mlindner@syskonnect.de */
- if (pdev->vendor == 0x11ab) {
- if ( (pdev->device == 0x4360) || (pdev->device == 0x4361) )
- continue;
- }
-
- SK_PCI_ISCOMPLIANT(vendor_flag, pdev);
- if (!vendor_flag)
- continue;
-
- /* Configure DMA attributes. */
- if (pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL) &&
- pci_set_dma_mask(pdev, (u64) 0xffffffff))
- continue;
-
-
- if ((dev = alloc_etherdev(sizeof(DEV_NET))) == NULL) {
- printk(KERN_ERR "Unable to allocate etherdev "
- "structure!\n");
- break;
- }
-
- pNet = dev->priv;
- pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL);
- if (pNet->pAC == NULL){
- free_netdev(dev);
- printk(KERN_ERR "Unable to allocate adapter "
- "structure!\n");
- break;
- }
+ retval = pci_enable_device(pdev);
+ if (retval)
+ goto err_out;
+
+ /* Configure DMA attributes. */
+ retval = pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL);
+ if (retval)
+ retval = pci_set_dma_mask(pdev, (u64) 0xffffffff);
+
+ if (retval) {
+ printk(KERN_ERR "Can't setup pci DMA\n");
+ goto err_out;
+ }
+
+ if ((dev = alloc_etherdev(sizeof(DEV_NET) + sizeof(SK_AC))) == NULL) {
+ printk(KERN_ERR "Unable to allocate etherdev "
+ "structure!\n");
+ retval = -ENOMEM;
+ goto err_out;
+ }
- /* Print message */
- if (!BootStringCount) {
- /* set display flag to TRUE so that */
- /* we only display this string ONCE */
- BootStringCount = SK_TRUE;
- printk("%s\n", BootString);
- }
+ pNet = dev->priv;
+ pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL);
+ if (pNet->pAC == NULL){
+ printk(KERN_ERR "Unable to allocate adapter "
+ "structure!\n");
+ goto free_dev_err;
+ }
- memset(pNet->pAC, 0, sizeof(SK_AC));
- pAC = pNet->pAC;
- pAC->PciDev = pdev;
- pAC->PciDevId = pdev->device;
- pAC->dev[0] = dev;
- pAC->dev[1] = dev;
- sprintf(pAC->Name, "SysKonnect SK-98xx");
- pAC->CheckQueue = SK_FALSE;
-
- pNet->Mtu = 1500;
- pNet->Up = 0;
- dev->irq = pdev->irq;
- retval = SkGeInitPCI(pAC);
- if (retval) {
- printk("SKGE: PCI setup failed: %i\n", retval);
- free_netdev(dev);
- continue;
- }
+ /* Print message */
+ if (!BootStringCount) {
+ /* set display flag to TRUE so that */
+ /* we only display this string ONCE */
+ BootStringCount = SK_TRUE;
+ printk("%s\n", BootString);
+ }
+
+ memset(pNet->pAC, 0, sizeof(SK_AC));
+ pAC = pNet->pAC;
+ pAC->PciDev = pdev;
+ pAC->PciDevId = pdev->device;
+ pAC->dev[0] = dev;
+ pAC->dev[1] = dev;
+ sprintf(pAC->Name, "SysKonnect SK-98xx");
+ pAC->CheckQueue = SK_FALSE;
+
+ pNet->Mtu = 1500;
+ pNet->Up = 0;
+ dev->irq = pdev->irq;
+ retval = SkGeInitPCI(pAC);
+ if (retval) {
+ printk("SKGE: PCI setup failed: %i\n", retval);
+ goto free_dev_err;
+ }
- SET_MODULE_OWNER(dev);
- dev->open = &SkGeOpen;
- dev->stop = &SkGeClose;
- dev->hard_start_xmit = &SkGeXmit;
- dev->get_stats = &SkGeStats;
- dev->last_stats = &SkGeStats;
- dev->set_multicast_list = &SkGeSetRxMode;
- dev->set_mac_address = &SkGeSetMacAddr;
- dev->do_ioctl = &SkGeIoctl;
- dev->change_mtu = &SkGeChangeMtu;
- dev->flags &= ~IFF_RUNNING;
- SET_NETDEV_DEV(dev, &pdev->dev);
+ SET_MODULE_OWNER(dev);
+ dev->open = &SkGeOpen;
+ dev->stop = &SkGeClose;
+ dev->hard_start_xmit = &SkGeXmit;
+ dev->get_stats = &SkGeStats;
+ dev->last_stats = &SkGeStats;
+ dev->set_multicast_list = &SkGeSetRxMode;
+ dev->set_mac_address = &SkGeSetMacAddr;
+ dev->do_ioctl = &SkGeIoctl;
+ dev->change_mtu = &SkGeChangeMtu;
+ dev->flags &= ~IFF_RUNNING;
+ SET_NETDEV_DEV(dev, &pdev->dev);
+ pci_set_drvdata(pdev, dev);
#ifdef SK_ZEROCOPY
#ifdef USE_SK_TX_CHECKSUM
- if (pAC->ChipsetType) {
- /* Use only if yukon hardware */
- /* SK and ZEROCOPY - fly baby... */
- dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
- }
+ if (pAC->ChipsetType) {
+ /* Use only if yukon hardware */
+ /* SK and ZEROCOPY - fly baby... */
+ dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
+ }
#endif
#endif
- pAC->Index = boards_found;
+ pAC->Index = ++boards_found;
- if (SkGeBoardInit(dev, pAC)) {
- free_netdev(dev);
- continue;
- }
+ if((retval = SkGeBoardInit(dev, pAC)) != 0)
+ goto free_dev_err;
- /* Register net device */
- if (register_netdev(dev)) {
- printk(KERN_ERR "SKGE: Could not register device.\n");
- FreeResources(dev);
- free_netdev(dev);
- continue;
- }
+ /* Register net device */
+ if ((retval = register_netdev(dev)) != 0) {
+ printk(KERN_ERR "SKGE: Could not register device.\n");
+ FreeResources(dev);
+ goto free_dev_err;
+ }
- /* Print adapter specific string from vpd */
- ProductStr(pAC);
- printk("%s: %s\n", dev->name, pAC->DeviceStr);
-
- /* Print configuration settings */
- printk(" PrefPort:%c RlmtMode:%s\n",
- 'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber,
- (pAC->RlmtMode==0) ? "Check Link State" :
- ((pAC->RlmtMode==1) ? "Check Link State" :
- ((pAC->RlmtMode==3) ? "Check Local Port" :
- ((pAC->RlmtMode==7) ? "Check Segmentation" :
- ((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error")))));
+ /* Print adapter specific string from vpd */
+ ProductStr(pAC);
+ printk("%s: %s\n", dev->name, pAC->DeviceStr);
+
+ /* Print configuration settings */
+ printk(" PrefPort:%c RlmtMode:%s\n",
+ 'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber,
+ (pAC->RlmtMode==0) ? "Check Link State" :
+ ((pAC->RlmtMode==1) ? "Check Link State" :
+ ((pAC->RlmtMode==3) ? "Check Local Port" :
+ ((pAC->RlmtMode==7) ? "Check Segmentation" :
+ ((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error")))));
- SkGeYellowLED(pAC, pAC->IoBase, 1);
+ SkGeYellowLED(pAC, pAC->IoBase, 1);
- memcpy((caddr_t) &dev->dev_addr,
- (caddr_t) &pAC->Addr.Net[0].CurrentMacAddress, 6);
+ memcpy((caddr_t) &dev->dev_addr,
+ (caddr_t) &pAC->Addr.Net[0].CurrentMacAddress, 6);
- /* First adapter... Create proc and print message */
+ /* First adapter... Create proc and print message */
#ifdef CONFIG_PROC_FS
- if (!DeviceFound) {
- DeviceFound = SK_TRUE;
- SK_MEMCPY(&SK_Root_Dir_entry, BootString,
- sizeof(SK_Root_Dir_entry) - 1);
-
- /*Create proc (directory)*/
- if(!pSkRootDir) {
- pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net);
- if (!pSkRootDir) {
- printk(KERN_WARNING "%s: Unable to create /proc/net/%s",
- dev->name, SK_Root_Dir_entry);
- } else {
- pSkRootDir->owner = THIS_MODULE;
- }
+ if (!DeviceFound) {
+ DeviceFound = SK_TRUE;
+ SK_MEMCPY(&SK_Root_Dir_entry, BootString,
+ sizeof(SK_Root_Dir_entry) - 1);
+
+ /*Create proc (directory)*/
+ if(!pSkRootDir) {
+ pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net);
+ if (!pSkRootDir) {
+ printk(KERN_WARNING "%s: Unable to create /proc/net/%s",
+ dev->name, SK_Root_Dir_entry);
+ } else {
+ pSkRootDir->owner = THIS_MODULE;
}
}
+ }
- /* Create proc file */
- if (pSkRootDir &&
- (pProcFile = create_proc_entry(dev->name, S_IRUGO,
- pSkRootDir))) {
- pProcFile->proc_fops = &sk_proc_fops;
- pProcFile->data = dev;
- }
+ /* Create proc file */
+ if (pSkRootDir &&
+ (pProcFile = create_proc_entry(dev->name, S_IRUGO,
+ pSkRootDir))) {
+ pProcFile->proc_fops = &sk_proc_fops;
+ pProcFile->data = dev;
+ }
#endif
- pNet->PortNr = 0;
- pNet->NetNr = 0;
+ pNet->PortNr = 0;
+ pNet->NetNr = 0;
- boards_found++;
+ boards_found++;
- /* More then one port found */
- if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
- if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) {
- printk(KERN_ERR "Unable to allocate etherdev "
- "structure!\n");
- break;
- }
+ /* More then one port found */
+ if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
+ if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) {
+ printk(KERN_ERR "Unable to allocate etherdev second"
+ "structure!\n");
+ goto skip;
+ }
- pAC->dev[1] = dev;
- pNet = dev->priv;
- pNet->PortNr = 1;
- pNet->NetNr = 1;
- pNet->pAC = pAC;
- pNet->Mtu = 1500;
- pNet->Up = 0;
-
- dev->open = &SkGeOpen;
- dev->stop = &SkGeClose;
- dev->hard_start_xmit = &SkGeXmit;
- dev->get_stats = &SkGeStats;
- dev->last_stats = &SkGeStats;
- dev->set_multicast_list = &SkGeSetRxMode;
- dev->set_mac_address = &SkGeSetMacAddr;
- dev->do_ioctl = &SkGeIoctl;
- dev->change_mtu = &SkGeChangeMtu;
- dev->flags &= ~IFF_RUNNING;
+ pAC->dev[1] = dev;
+ pNet = dev->priv;
+ pNet->PortNr = 1;
+ pNet->NetNr = 1;
+ pNet->pAC = pAC;
+ pNet->Mtu = 1500;
+ pNet->Up = 0;
+
+ dev->open = &SkGeOpen;
+ dev->stop = &SkGeClose;
+ dev->hard_start_xmit = &SkGeXmit;
+ dev->get_stats = &SkGeStats;
+ dev->last_stats = &SkGeStats;
+ dev->set_multicast_list = &SkGeSetRxMode;
+ dev->set_mac_address = &SkGeSetMacAddr;
+ dev->do_ioctl = &SkGeIoctl;
+ dev->change_mtu = &SkGeChangeMtu;
+ dev->flags &= ~IFF_RUNNING;
#ifdef SK_ZEROCOPY
#ifdef USE_SK_TX_CHECKSUM
- if (pAC->ChipsetType) {
- /* SG and ZEROCOPY - fly baby... */
- dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
- }
+ if (pAC->ChipsetType) {
+ /* SG and ZEROCOPY - fly baby... */
+ dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
+ }
#endif
#endif
- if (register_netdev(dev)) {
- printk(KERN_ERR "SKGE: Could not register device.\n");
- free_netdev(dev);
- pAC->dev[1] = pAC->dev[0];
- } else {
+ if (register_netdev(dev)) {
+ printk(KERN_ERR "SKGE: Could not register device.\n");
+ free_netdev(dev);
+ pAC->dev[1] = pAC->dev[0];
+ } else {
#ifdef CONFIG_PROC_FS
- if (pSkRootDir
- && (pProcFile = create_proc_entry(dev->name,
- S_IRUGO, pSkRootDir))) {
- pProcFile->proc_fops = &sk_proc_fops;
- pProcFile->data = dev;
- }
+ if (pSkRootDir
+ && (pProcFile = create_proc_entry(dev->name,
+ S_IRUGO, pSkRootDir))) {
+ pProcFile->proc_fops = &sk_proc_fops;
+ pProcFile->data = dev;
+ }
#endif
memcpy((caddr_t) &dev->dev_addr,
- (caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6);
+ (caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6);
printk("%s: %s\n", dev->name, pAC->DeviceStr);
printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
- }
}
-
- /* Save the hardware revision */
- pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
- (pAC->GIni.GIPciHwRev & 0x0F);
-
- /* Set driver globals */
- pAC->Pnmi.pDriverFileName = DRIVER_FILE_NAME;
- pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE;
-
- SK_MEMSET(&(pAC->PnmiBackup), 0, sizeof(SK_PNMI_STRUCT_DATA));
- SK_MEMCPY(&(pAC->PnmiBackup), &(pAC->PnmiStruct),
- sizeof(SK_PNMI_STRUCT_DATA));
-
- /*
- * This is bollocks, but we need to tell the net-init
- * code that it shall go for the next device.
- */
-#ifndef MODULE
- dev->base_addr = 0;
-#endif
}
- /*
- * If we're at this point we're going through skge_probe() for
- * the first time. Return success (0) if we've initialized 1
- * or more boards. Otherwise, return failure (-ENODEV).
- */
+ skip:
+ /* Save the hardware revision */
+ pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
+ (pAC->GIni.GIPciHwRev & 0x0F);
+
+ /* Set driver globals */
+ pAC->Pnmi.pDriverFileName = DRIVER_FILE_NAME;
+ pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE;
+
+ SK_MEMSET(&(pAC->PnmiBackup), 0, sizeof(SK_PNMI_STRUCT_DATA));
+ SK_MEMCPY(&(pAC->PnmiBackup), &(pAC->PnmiStruct),
+ sizeof(SK_PNMI_STRUCT_DATA));
+
+ return 0;
- return boards_found;
-} /* skge_probe */
+ free_dev_err:
+ pci_set_drvdata(pdev, NULL);
+ free_netdev(dev);
+ err_out:
+ return retval;
+}
/*****************************************************************************
@@ -755,9 +741,6 @@
static char *RlmtMode[SK_MAX_CARD_PARAM] = {"", };
#endif
-static int debug = 0; /* not used */
-static int options[SK_MAX_CARD_PARAM] = {0, }; /* not used */
-
static int IntsPerSec[SK_MAX_CARD_PARAM];
static char *Moderation[SK_MAX_CARD_PARAM];
static char *ModerationMask[SK_MAX_CARD_PARAM];
@@ -765,12 +748,72 @@
static char *Stats[SK_MAX_CARD_PARAM];
+static void __devexit skge_remove_one(struct pci_dev *pdev)
+{
+ struct SK_NET_DEVICE *dev = pci_get_drvdata(pdev);
+ DEV_NET *pNet = dev->priv;
+ SK_AC *pAC = pNet->pAC;
+ unsigned long Flags;
+ SK_EVPARA EvPara;
+
+ netif_stop_queue(SkGeRootDev);
+ SkGeYellowLED(pAC, pAC->IoBase, 0);
+
+ if(pAC->BoardLevel == SK_INIT_RUN) {
+ /* board is still alive */
+ spin_lock_irqsave(&pAC->SlowPathLock, Flags);
+ EvPara.Para32[0] = 0;
+ EvPara.Para32[1] = -1;
+ SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
+ EvPara.Para32[0] = 1;
+ EvPara.Para32[1] = -1;
+ SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
+ SkEventDispatcher(pAC, pAC->IoBase);
+ /* disable interrupts */
+ SK_OUT32(pAC->IoBase, B0_IMSK, 0);
+ SkGeDeInit(pAC, pAC->IoBase);
+ spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
+ pAC->BoardLevel = SK_INIT_DATA;
+ /* We do NOT check here, if IRQ was pending, of course*/
+ }
+
+ if(pAC->BoardLevel == SK_INIT_IO) {
+ /* board is still alive */
+ SkGeDeInit(pAC, pAC->IoBase);
+ pAC->BoardLevel = SK_INIT_DATA;
+ }
+
+ if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 2){
+ unregister_netdev(pAC->dev[1]);
+ free_netdev(pAC->dev[1]);
+ }
+
+ FreeResources(SkGeRootDev);
+
+ SkGeRootDev->get_stats = NULL;
+ /*
+ * otherwise unregister_netdev calls get_stats with
+ * invalid IO ... :-(
+ */
+ unregister_netdev(SkGeRootDev);
+ free_netdev(SkGeRootDev);
+ kfree(pAC);
+} /* skge_remove */
+
+static struct pci_driver skge_driver = {
+ .name = "skge",
+ .id_table = skge_pci_table,
+ .probe = skge_init_one,
+ .remove = __devexit_p(skge_remove_one),
+};
+
+
/*****************************************************************************
*
* skge_init_module - module initialization function
*
* Description:
- * Very simple, only call skge_probe and return approriate result.
+ * Very simple, call pci registation
*
* Returns:
* 0, if everything is ok
@@ -778,18 +821,7 @@
*/
static int __init skge_init_module(void)
{
- int cards;
- SkGeRootDev = NULL;
-
- /* just to avoid warnings ... */
- debug = 0;
- options[0] = 0;
-
- cards = skge_probe();
- if (cards == 0) {
- printk("sk98lin: No adapter found.\n");
- }
- return cards ? 0 : -ENODEV;
+ return pci_module_init(&skge_driver);
} /* skge_init_module */
@@ -805,68 +837,14 @@
*/
static void __exit skge_cleanup_module(void)
{
-DEV_NET *pNet;
-SK_AC *pAC;
-struct SK_NET_DEVICE *next;
-unsigned long Flags;
-SK_EVPARA EvPara;
-
- while (SkGeRootDev) {
- pNet = (DEV_NET*) SkGeRootDev->priv;
- pAC = pNet->pAC;
- next = pAC->Next;
-
- netif_stop_queue(SkGeRootDev);
- SkGeYellowLED(pAC, pAC->IoBase, 0);
-
- if(pAC->BoardLevel == SK_INIT_RUN) {
- /* board is still alive */
- spin_lock_irqsave(&pAC->SlowPathLock, Flags);
- EvPara.Para32[0] = 0;
- EvPara.Para32[1] = -1;
- SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
- EvPara.Para32[0] = 1;
- EvPara.Para32[1] = -1;
- SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
- SkEventDispatcher(pAC, pAC->IoBase);
- /* disable interrupts */
- SK_OUT32(pAC->IoBase, B0_IMSK, 0);
- SkGeDeInit(pAC, pAC->IoBase);
- spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
- pAC->BoardLevel = SK_INIT_DATA;
- /* We do NOT check here, if IRQ was pending, of course*/
- }
-
- if(pAC->BoardLevel == SK_INIT_IO) {
- /* board is still alive */
- SkGeDeInit(pAC, pAC->IoBase);
- pAC->BoardLevel = SK_INIT_DATA;
- }
-
- if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 2){
- unregister_netdev(pAC->dev[1]);
- free_netdev(pAC->dev[1]);
- }
-
- FreeResources(SkGeRootDev);
-
- SkGeRootDev->get_stats = NULL;
- /*
- * otherwise unregister_netdev calls get_stats with
- * invalid IO ... :-(
- */
- unregister_netdev(SkGeRootDev);
- free_netdev(SkGeRootDev);
- kfree(pAC);
- SkGeRootDev = next;
- }
+ pci_unregister_driver(&skge_driver);
#ifdef CONFIG_PROC_FS
/* clear proc-dir */
remove_proc_entry(pSkRootDir->name, proc_net);
#endif
-} /* skge_cleanup_module */
+}
module_init(skge_init_module);
module_exit(skge_cleanup_module);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFT] convert syskonnect gigabit ether driver to PCI module interface
2004-06-22 23:11 [RFT] convert syskonnect gigabit ether driver to PCI module interface Stephen Hemminger
@ 2004-06-22 23:23 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2004-06-22 23:23 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Mirko Lindner, Ralph Roesler, netdev, Christoph Hellwig
Stephen Hemminger wrote:
> This patch converts the SysKonnect Gigabit Ethernet (Yukon) driver from
> the old pci_find_class infrastructure, to the current 2.4/2.6 pci_module probing
> model. The device identification is no longer done in the macro, but in a pci_device_id
> table like other drivers.
Didn't Christoph just submit this same patch? :)
Jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-06-22 23:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-22 23:11 [RFT] convert syskonnect gigabit ether driver to PCI module interface Stephen Hemminger
2004-06-22 23:23 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).