Merge branch 'upstream-fixes'
authorJeff Garzik <jgarzik@pobox.com>
Tue, 13 Dec 2005 05:07:46 +0000 (00:07 -0500)
committerJeff Garzik <jgarzik@pobox.com>
Tue, 13 Dec 2005 05:07:46 +0000 (00:07 -0500)
1  2 
drivers/net/sk98lin/skge.c

index e3bdb58360011f853a10f3747de2ce89a7eca14e,ae734393475876a6c0bd9ce521fb714967c15f21..e5591d33dd284fab3a9fa4b6f870cec85753eb96
  #include      <linux/module.h>
  #include      <linux/moduleparam.h>
  #include      <linux/init.h>
 -#include      <linux/proc_fs.h>
  #include      <linux/dma-mapping.h>
  #include      <linux/ip.h>
  
@@@ -205,6 -206,7 +205,6 @@@ static void        SkGeSetRxMode(struct SK_NET
  static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev);
  static int    SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd);
  static void   GetConfiguration(SK_AC*);
 -static void   ProductStr(SK_AC*);
  static int    XmitFrame(SK_AC*, TX_PORT*, struct sk_buff*);
  static void   FreeTxDescriptors(SK_AC*pAC, TX_PORT*);
  static void   FillRxRing(SK_AC*, RX_PORT*);
@@@ -233,6 -235,28 +233,6 @@@ static int      SkDrvDeInitAdapter(SK_A
   * Extern Function Prototypes
   *
   ******************************************************************************/
 -static const char     SKRootName[] = "net/sk98lin";
 -static struct         proc_dir_entry *pSkRootDir;
 -extern struct file_operations sk_proc_fops;
 -
 -static inline void SkGeProcCreate(struct net_device *dev)
 -{
 -      struct proc_dir_entry *pe;
 -
 -      if (pSkRootDir && 
 -          (pe = create_proc_entry(dev->name, S_IRUGO, pSkRootDir))) {
 -              pe->proc_fops = &sk_proc_fops;
 -              pe->data = dev;
 -              pe->owner = THIS_MODULE;
 -      }
 -}
 - 
 -static inline void SkGeProcRemove(struct net_device *dev)
 -{
 -      if (pSkRootDir)
 -              remove_proc_entry(dev->name, pSkRootDir);
 -}
 -
  extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);        
  extern void SkDimDisplayModerationSettings(SK_AC *pAC);
  extern void SkDimStartModerationTimer(SK_AC *pAC);
@@@ -253,27 -277,6 +253,27 @@@ extern  struct ethtool_ops SkGeEthtoolO
  static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
  static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
  
 +/*****************************************************************************
 + *
 + *    SkPciWriteCfgDWord - write a 32 bit value to pci config space
 + *
 + * Description:
 + *    This routine writes a 32 bit value to the pci configuration
 + *    space.
 + *
 + * Returns:
 + *    0 - indicate everything worked ok.
 + *    != 0 - error indication
 + */
 +static inline int SkPciWriteCfgDWord(
 +SK_AC *pAC,   /* Adapter Control structure pointer */
 +int PciAddr,          /* PCI register address */
 +SK_U32 Val)           /* pointer to store the read value */
 +{
 +      pci_write_config_dword(pAC->PciDev, PciAddr, Val);
 +      return(0);
 +} /* SkPciWriteCfgDWord */
 +
  /*****************************************************************************
   *
   *    SkGeInitPCI - Init the PCI resources
@@@ -297,7 -300,7 +297,7 @@@ int SkGeInitPCI(SK_AC *pAC
        dev->mem_start = pci_resource_start (pdev, 0);
        pci_set_master(pdev);
  
 -      if (pci_request_regions(pdev, pAC->Name) != 0) {
 +      if (pci_request_regions(pdev, "sk98lin") != 0) {
                retval = 2;
                goto out_disable;
        }
@@@ -575,10 -578,10 +575,10 @@@ SK_BOOL DualNet
        spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
  
        if (pAC->GIni.GIMacsFound == 2) {
 -               Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev);
 +               Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev);
        } else if (pAC->GIni.GIMacsFound == 1) {
                Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ,
 -                      pAC->Name, dev);
 +                      "sk98lin", dev);
        } else {
                printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n",
                       pAC->GIni.GIMacsFound);
@@@ -815,7 -818,7 +815,7 @@@ uintptr_t VNextDescr;      /* the virtual bu
                /* set the pointers right */
                pDescr->VNextRxd = VNextDescr & 0xffffffffULL;
                pDescr->pNextRxd = pNextDescr;
-               pDescr->TcpSumStarts = 0;
+               if (!IsTx) pDescr->TcpSumStarts = ETH_HLEN << 16 | ETH_HLEN;
  
                /* advance one step */
                pPrevDescr = pDescr;
@@@ -1262,6 -1265,7 +1262,6 @@@ struct SK_NET_DEVICE    *dev
        spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
  
        pAC->MaxPorts++;
 -      pNet->Up = 1;
  
  
        SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
@@@ -1391,6 -1395,7 +1391,6 @@@ struct SK_NET_DEVICE    *dev
                        sizeof(SK_PNMI_STRUCT_DATA));
  
        pAC->MaxPorts--;
 -      pNet->Up = 0;
  
        return (0);
  } /* SkGeClose */
@@@ -2163,11 -2168,14 +2163,13 @@@ rx_start
                        skb_put(pMsg, FrameLength);
                } /* frame > SK_COPY_TRESHOLD */
  
-               if (pRxPort->RxCsum) {
-                       pMsg->csum = pRxd->TcpSums;
-                       pMsg->ip_summed = CHECKSUM_HW;
-               }
+ #ifdef USE_SK_RX_CHECKSUM
+               pMsg->csum = pRxd->TcpSums & 0xffff;
+               pMsg->ip_summed = CHECKSUM_HW;
+ #else
+               pMsg->ip_summed = CHECKSUM_NONE;
+ #endif
  
 -
                SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V"));
                ForRlmt = SK_RLMT_RX_PROTOCOL;
  #if 0
@@@ -2542,7 -2550,7 +2544,7 @@@ unsigned long           Flags
  static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int NewMtu)
  {
  DEV_NET               *pNet;
 -DEV_NET               *pOtherNet;
 +struct net_device *pOtherDev;
  SK_AC         *pAC;
  unsigned long Flags;
  int           i;
@@@ -2572,11 -2580,11 +2574,11 @@@ SK_EVPARA    EvPara
        }
  #endif
  
 -      pNet->Mtu = NewMtu;
 -      pOtherNet = netdev_priv(pAC->dev[1 - pNet->NetNr]);
 -      if ((pOtherNet->Mtu>1500) && (NewMtu<=1500) && (pOtherNet->Up==1)) {
 -              return(0);
 -      }
 +      pOtherDev = pAC->dev[1 - pNet->NetNr];
 +
 +      if ( netif_running(pOtherDev) && (pOtherDev->mtu > 1500)
 +           && (NewMtu <= 1500))
 +              return 0;
  
        pAC->RxBufSize = NewMtu + 32;
        dev->mtu = NewMtu;
                EvPara.Para32[1] = -1;
                SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
                        
 -              if (pOtherNet->Up) {
 +              if (netif_running(pOtherDev)) {
 +                      DEV_NET *pOtherNet = netdev_priv(pOtherDev);
                        EvPara.Para32[0] = pOtherNet->PortNr;
                        SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
                }
@@@ -2813,7 -2820,7 +2815,7 @@@ unsigned long   Flags;                  /* for spin loc
        pAC->stats.rx_bytes = (SK_U32) pPnmiStruct->RxOctetsDeliveredCts;
        pAC->stats.tx_bytes = (SK_U32) pPnmiStat->StatTxOctetsOkCts;
        
 -        if (pNet->Mtu <= 1500) {
 +        if (dev->mtu <= 1500) {
                  pAC->stats.rx_errors = (SK_U32) pPnmiStruct->InErrorsCts & 0xFFFFFFFF;
          } else {
                  pAC->stats.rx_errors = (SK_U32) ((pPnmiStruct->InErrorsCts -
@@@ -3764,21 -3771,25 +3766,21 @@@ int  Capabilities[3][3] 
   *
   * Returns: N/A
   */
 -static void ProductStr(
 -SK_AC *pAC            /* pointer to adapter context */
 +static inline int ProductStr(
 +      SK_AC   *pAC,           /* pointer to adapter context */
 +      char    *DeviceStr,     /* result string */
 +      int      StrLen         /* length of the string */
  )
  {
 -int   StrLen = 80;            /* length of the string, defined in SK_AC */
  char  Keyword[] = VPD_NAME;   /* vpd productname identifier */
  int   ReturnCode;             /* return code from vpd_read */
  unsigned long Flags;
  
        spin_lock_irqsave(&pAC->SlowPathLock, Flags);
 -      ReturnCode = VpdRead(pAC, pAC->IoBase, Keyword, pAC->DeviceStr,
 -              &StrLen);
 +      ReturnCode = VpdRead(pAC, pAC->IoBase, Keyword, DeviceStr, &StrLen);
        spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 -      if (ReturnCode != 0) {
 -              /* there was an error reading the vpd data */
 -              SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ERROR,
 -                      ("Error reading VPD data: %d\n", ReturnCode));
 -              pAC->DeviceStr[0] = '\0';
 -      }
 +
 +      return ReturnCode;
  } /* ProductStr */
  
  /*****************************************************************************
@@@ -3979,6 -3990,28 +3981,6 @@@ SK_U8 *pVal)           /* pointer to store the r
  } /* SkPciReadCfgByte */
  
  
 -/*****************************************************************************
 - *
 - *    SkPciWriteCfgDWord - write a 32 bit value to pci config space
 - *
 - * Description:
 - *    This routine writes a 32 bit value to the pci configuration
 - *    space.
 - *
 - * Returns:
 - *    0 - indicate everything worked ok.
 - *    != 0 - error indication
 - */
 -int SkPciWriteCfgDWord(
 -SK_AC *pAC,   /* Adapter Control structure pointer */
 -int PciAddr,          /* PCI register address */
 -SK_U32 Val)           /* pointer to store the read value */
 -{
 -      pci_write_config_dword(pAC->PciDev, PciAddr, Val);
 -      return(0);
 -} /* SkPciWriteCfgDWord */
 -
 -
  /*****************************************************************************
   *
   *    SkPciWriteCfgWord - write a 16 bit value to pci config space
@@@ -4117,7 -4150,6 +4119,7 @@@ SK_BOOL         DualNet
                        Flags);
                break;
        case SK_DRV_NET_UP:      /* SK_U32 PortIdx */
 +      {       struct net_device *dev = pAC->dev[Param.Para32[0]];
                /* action list 5 */
                FromPort = Param.Para32[0];
                SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
                        printk("    irq moderation:  disabled\n");
  
  
 -#ifdef SK_ZEROCOPY
 -              if (pAC->ChipsetType)
 -#ifdef USE_SK_TX_CHECKSUM
 -                      printk("    scatter-gather:  enabled\n");
 -#else
 -                      printk("    tx-checksum:     disabled\n");
 -#endif
 -              else
 -                      printk("    scatter-gather:  disabled\n");
 -#else
 -                      printk("    scatter-gather:  disabled\n");
 -#endif
 -
 -#ifndef USE_SK_RX_CHECKSUM
 -                      printk("    rx-checksum:     disabled\n");
 -#endif
 +              printk("    scatter-gather:  %s\n",
 +                     (dev->features & NETIF_F_SG) ? "enabled" : "disabled");
 +              printk("    tx-checksum:     %s\n",
 +                     (dev->features & NETIF_F_IP_CSUM) ? "enabled" : "disabled");
 +              printk("    rx-checksum:     %s\n",
 +                     pAC->RxPort[Param.Para32[0]].RxCsum ? "enabled" : "disabled");
  
                } else {
                          DoPrintInterfaceChange = SK_TRUE;
                }
  
                /* Inform the world that link protocol is up. */
 -              netif_carrier_on(pAC->dev[Param.Para32[0]]);
 -
 +              netif_carrier_on(dev);
                break;
 +      }
        case SK_DRV_NET_DOWN:    /* SK_U32 Reason */
                /* action list 7 */
                SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
@@@ -4437,7 -4479,7 +4439,7 @@@ SK_AC   *pAc)   /* pointer to adapter c
  
        pAC->DiagModeActive = DIAG_ACTIVE;
        if (pAC->BoardLevel > SK_INIT_DATA) {
 -              if (pNet->Up) {
 +              if (netif_running(pAC->dev[0])) {
                        pAC->WasIfUp[0] = SK_TRUE;
                        pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose      */
                        DoPrintInterfaceChange = SK_FALSE;
                }
                if (pNet != netdev_priv(pAC->dev[1])) {
                        pNet = netdev_priv(pAC->dev[1]);
 -                      if (pNet->Up) {
 +                      if (netif_running(pAC->dev[1])) {
                                pAC->WasIfUp[1] = SK_TRUE;
                                pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
                                DoPrintInterfaceChange = SK_FALSE;
@@@ -4773,7 -4815,6 +4775,7 @@@ static int __devinit skge_probe_one(str
        struct net_device       *dev = NULL;
        static int boards_found = 0;
        int error = -ENODEV;
 +      char DeviceStr[80];
  
        if (pci_enable_device(pdev))
                goto out;
        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;
        error = SkGeInitPCI(pAC);
        if (error) {
        SET_NETDEV_DEV(dev, &pdev->dev);
        SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
  
 -#ifdef SK_ZEROCOPY
 -#ifdef USE_SK_TX_CHECKSUM
 +      /* Use only if yukon hardware */
        if (pAC->ChipsetType) {
 -              /* Use only if yukon hardware */
 -              /* SK and ZEROCOPY - fly baby... */
 -              dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
 -      }
 +#ifdef USE_SK_TX_CHECKSUM
 +              dev->features |= NETIF_F_IP_CSUM;
 +#endif
 +#ifdef SK_ZEROCOPY
 +              dev->features |= NETIF_F_SG;
  #endif
 +#ifdef USE_SK_RX_CHECKSUM
 +              pAC->RxPort[0].RxCsum = 1;
  #endif
 +      }
  
        pAC->Index = boards_found++;
  
        if (SkGeBoardInit(dev, pAC))
                goto out_free_netdev;
  
 +      /* Read Adapter name from VPD */
 +      if (ProductStr(pAC, DeviceStr, sizeof(DeviceStr)) != 0) {
 +              printk(KERN_ERR "sk98lin: Could not read VPD data.\n");
 +              goto out_free_resources;
 +      }
 +
        /* Register net device */
        if (register_netdev(dev)) {
                printk(KERN_ERR "sk98lin: Could not register device.\n");
        }
  
        /* Print adapter specific string from vpd */
 -      ProductStr(pAC);
 -      printk("%s: %s\n", dev->name, pAC->DeviceStr);
 +      printk("%s: %s\n", dev->name, DeviceStr);
  
        /* Print configuration settings */
        printk("      PrefPort:%c  RlmtMode:%s\n",
        memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
        memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
  
 -      SkGeProcCreate(dev);
 -
        pNet->PortNr = 0;
        pNet->NetNr  = 0;
  
                pNet->PortNr  = 1;
                pNet->NetNr   = 1;
                pNet->pAC     = pAC;
 -              pNet->Mtu     = 1500;
 -              pNet->Up      = 0;
  
                dev->open               = &SkGeOpen;
                dev->stop               = &SkGeClose;
                SET_NETDEV_DEV(dev, &pdev->dev);
                SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
  
 -#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;
 -              }
 +#ifdef USE_SK_TX_CHECKSUM
 +                      dev->features |= NETIF_F_IP_CSUM;
 +#endif
 +#ifdef SK_ZEROCOPY
 +                      dev->features |= NETIF_F_SG;
  #endif
 +#ifdef USE_SK_RX_CHECKSUM
 +                      pAC->RxPort[1].RxCsum = 1;
  #endif
 +              }
  
                if (register_netdev(dev)) {
                        printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n");
                        free_netdev(dev);
                        pAC->dev[1] = pAC->dev[0];
                } else {
 -                      SkGeProcCreate(dev);
                        memcpy(&dev->dev_addr,
                                        &pAC->Addr.Net[1].CurrentMacAddress, 6);
                        memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
        
 -                      printk("%s: %s\n", dev->name, pAC->DeviceStr);
 +                      printk("%s: %s\n", dev->name, DeviceStr);
                        printk("      PrefPort:B  RlmtMode:Dual Check Link State\n");
                }
        }
@@@ -4962,7 -5000,10 +4964,7 @@@ static void __devexit skge_remove_one(s
        SK_AC *pAC = pNet->pAC;
        struct net_device *otherdev = pAC->dev[1];
  
 -      SkGeProcRemove(dev);
        unregister_netdev(dev);
 -      if (otherdev != dev)
 -              SkGeProcRemove(otherdev);
  
        SkGeYellowLED(pAC, pAC->IoBase, 0);
  
@@@ -5047,9 -5088,9 +5049,9 @@@ static int skge_resume(struct pci_dev *
        pci_enable_device(pdev);
        pci_set_master(pdev);
        if (pAC->GIni.GIMacsFound == 2)
 -              ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev);
 +              ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev);
        else
 -              ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, pAC->Name, dev);
 +              ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, "sk98lin", dev);
        if (ret) {
                printk(KERN_WARNING "sk98lin: unable to acquire IRQ %d\n", dev->irq);
                pAC->AllocFlag &= ~SK_ALLOC_IRQ;
@@@ -5107,12 -5148,23 +5109,12 @@@ static struct pci_driver skge_driver = 
  
  static int __init skge_init(void)
  {
 -      int error;
 -
 -      pSkRootDir = proc_mkdir(SKRootName, NULL);
 -      if (pSkRootDir) 
 -              pSkRootDir->owner = THIS_MODULE;
 -      
 -      error = pci_register_driver(&skge_driver);
 -      if (error)
 -              remove_proc_entry(SKRootName, NULL);
 -      return error;
 +      return pci_module_init(&skge_driver);
  }
  
  static void __exit skge_exit(void)
  {
        pci_unregister_driver(&skge_driver);
 -      remove_proc_entry(SKRootName, NULL);
 -
  }
  
  module_init(skge_init);
This page took 0.051392 seconds and 5 git commands to generate.