new sk98lin driver
Subsystems (2)
Hi,
there's a new sk98lin driver available from
http://www.syskonnect.com/syskonnect/support/driver/zip/linux/install-7_09.tar.bz2
(now with ethtool support) dated Oct 20. It's not in 2.6.10-rc1, will it be included in 2.6.10?
Thanks,
Michael
Quoted 6 lines · Michael Heyse
Hi,
there's a new sk98lin driver available from
http://www.syskonnect.com/syskonnect/support/driver/zip/linux/install-7_09.tar.bz2(now with ethtool support) dated Oct 20. It's not in 2.6.10-rc1, will it be included in 2.6.10?
I think Stephen Hemminger volunteered to split up the changes into separate patches.
Jeff
Quoted 11 lines · Jeff Garzik
Quoted 6 lines · Michael Heyse
Hi,
there's a new sk98lin driver available from
http://www.syskonnect.com/syskonnect/support/driver/zip/linux/install-7_09.tar.bz2(now with ethtool support) dated Oct 20. It's not in 2.6.10-rc1, will it be included in 2.6.10?
I think Stephen Hemminger volunteered to split up the changes into separate patches.
OK, that will probably take quite a while, the patch is large. Thanks for the info!
Michael
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 (2/23) sk98: local variable can be constant
The table OnesHash is only used in this file, and should be made a local constant.
drivers/net/sk98lin/skaddr.c +1 -1
@@ -79,7 +79,7 @@/* 64-bit hash values with all bits set. */ -SK_U16 OnesHash[4 ] = {0xFFFF ,0xFFFF ,0xFFFF ,0xFFFF }; +static const SK_U16 OnesHash[4 ] = {0xFFFF ,0xFFFF ,0xFFFF ,0xFFFF };/* local variables ************************************************************/
PATCH 1/1 (3/23) sk98: /proc interface related changes
In reply to a message not in the archiveThe /proc intereface can be cleaned up a lot:
+ Pass the device to through the proc data/seq_private hook.
+ No longer needs to have a list of network devices
+ use seq_printf directly rather than indirection into a buffer
+ failure to create proc directory or interface should not be fatal.
+ if PROC_FS not configured, let the stubs cause the necessary code elimination rather than using #ifdef
drivers/net/sk98lin/h/skdrv2nd.h +1 -2
@@ -266,7 +266,6 @@typedef struct s_DevNet DEV_NET ;struct s_DevNet { -struct proc_dir_entry *proc;int PortNr;int NetNr;int Mtu;
@@ -395,7 +394,7 @@SK_U32 PciDevId;/* pci device id */ struct SK_NET_DEVICE *dev[2 ];/* pointer to device struct */ char Name[30 ];/* driver name */ -struct SK_NET_DEVICE *Next;/* link all devices (for clearing) */ +int RxBufSize;/* length of receive buffers */ struct net_device_stats stats;/* linux 'netstat -i' statistics */ int Index;/* internal board index number */
drivers/net/sk98lin/skge.c +37 -66
166 lines not on this page · raw message
drivers/net/sk98lin/skproc.c +170 -283
498 lines not on this page · raw message
Re: [PATCH] (3/23) sk98: /proc interface related changes
Quoted 8 lines · Stephen Hemminger
The /proc intereface can be cleaned up a lot:
+ Pass the device to through the proc data/seq_private hook.
+ No longer needs to have a list of network devices
+ useseq_printfdirectly rather than indirection into a buffer
+ failure to create proc directory or interface should not be fatal.
+ ifPROC_FSnot configured, let the stubs cause the necessary code elimination rather than using #ifdef
This is still totally broken because dev->name may change between registration and removal. If a netdriver wants to use procfs file per-adapter it needs to use an enumeration scheme independant of the netdevice naming. Or even better stop using procfs at all.
Re: [PATCH] (3/23) sk98: /proc interface related changes
Quoted 10 lines · Stephen Hemminger
Quoted 8 lines
The /proc intereface can be cleaned up a lot:
+ Pass the device to through the proc data/seq_private hook.
+ No longer needs to have a list of network devices
+ useseq_printfdirectly rather than indirection into a buffer
+ failure to create proc directory or interface should not be fatal.
+ ifPROC_FSnot configured, let the stubs cause the necessary code elimination rather than using #ifdef
Quoted 4 lines
This is still totally broken because
dev->namemay change between registration and removal. If a netdriver wants to use procfs file per-adapter it needs to use an enumeration scheme independant of the netdevice naming. Or even better stop using procfs at all.
I would prefer to get rid of /proc interface altogether. I will unless SysKonnect says they have some application depending on it.
There are a few statistics that don't show up in ethtool, but it wouldn't be hard to add those (or put them in sysfs).
PATCH 1/1 (4/23) sk98: use netdev_priv
In reply to a message not in the archiveUse netdev_priv when dereferenceing net_device private
drivers/net/sk98lin/skge.c +33 -38
@@ -337,22 +337,20 @@DEV_NET *pNet;SK_AC *pAC; -if (dev->priv) { - pNet = (DEV_NET *) dev->priv; - pAC = pNet->pAC; - AllocFlag = pAC->AllocFlag; -if (pAC->PciDev) { -pci_release_regions (pAC->PciDev); - } -if (AllocFlag &SK_ALLOC_IRQ ) { -free_irq (dev->irq, dev); - } -if (pAC->IoBase) { -iounmap (pAC->IoBase); - } -if (pAC->pDescrMem) { -BoardFreeMem (pAC); - } + pNet =netdev_priv (dev); + pAC = pNet->pAC; + AllocFlag = pAC->AllocFlag; +if (pAC->PciDev) { +pci_release_regions (pAC->PciDev); + } +if (AllocFlag &SK_ALLOC_IRQ ) { +free_irq (dev->irq, dev); + } +if (pAC->IoBase) { +iounmap (pAC->IoBase); + } +if (pAC->pDescrMem) { +BoardFreeMem (pAC); } }/* FreeResources */
@@ -887,7 +885,7 @@SK_AC *pAC;SK_U32 IntSrc;/* interrupts source register contents */ - pNet = (DEV_NET *) dev->priv; + pNet =netdev_priv (dev); pAC = pNet->pAC;/*
@@ -1036,7 +1034,7 @@SK_AC *pAC;SK_U32 IntSrc;/* interrupts source register contents */ - pNet = (DEV_NET *) dev->priv; + pNet =netdev_priv (dev); pAC = pNet->pAC;/*
@@ -1152,7 +1150,7 @@int i;SK_EVPARA EvPara;/* an event parameter union */ - pNet = (DEV_NET *) dev->priv; + pNet =netdev_priv (dev); pAC = pNet->pAC; SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
@@ -1273,7 +1271,7 @@SK_DBG_MSG (NULL ,SK_DBGMOD_DRV ,SK_DBGCAT_DRV_ENTRY , ("SkGeClose: pAC=0x%lX " , (unsigned long )pAC)); - pNet = (DEV_NET *) dev->priv; + pNet =netdev_priv (dev); pAC = pNet->pAC;#ifdef SK_DIAG_SUPPORT
@@ -1284,7 +1282,7 @@** by operator interaction must not be started up ** again when the DIAG has finished. */ - newPtrNet = (DEV_NET *) pAC->dev[0 ]->priv; + newPtrNet =netdev_priv (pAC->dev[0 ]);if (newPtrNet == pNet) { pAC->WasIfUp[0 ] =SK_FALSE ; }else {
@@ -1394,7 +1392,7 @@SK_AC *pAC;int Rc;/* return code of XmitFrame */ - pNet = (DEV_NET *) dev->priv; + pNet =netdev_priv (dev); pAC = pNet->pAC; if ((!skb_shinfo(skb)->nr_frags) ||
@@ -2490,7 +2488,7 @@static int SkGeSetMacAddr (struct SK_NET_DEVICE *dev,void *p) { -DEV_NET *pNet = (DEV_NET *) dev->priv; +DEV_NET *pNet =netdev_priv (dev);SK_AC *pAC = pNet->pAC;struct sockaddr *addr = p;
@@ -2547,7 +2545,7 @@SK_DBG_MSG (NULL ,SK_DBGMOD_DRV ,SK_DBGCAT_DRV_ENTRY , ("SkGeSetRxMode starts now... " )); - pNet = (DEV_NET *) dev->priv; + pNet =netdev_priv (dev); pAC = pNet->pAC;if (pAC->RlmtNets ==1 ) PortIdx = pAC->ActivePort;
@@ -2619,7 +2617,7 @@SK_DBG_MSG (NULL ,SK_DBGMOD_DRV ,SK_DBGCAT_DRV_ENTRY , ("SkGeChangeMtu starts now...\n" )); - pNet = (DEV_NET *) dev->priv; + pNet =netdev_priv (dev); pAC = pNet->pAC;if ((NewMtu <68 ) || (NewMtu >SK_JUMBO_MTU )) {
@@ -2641,7 +2639,7 @@#endif pNet->Mtu = NewMtu; - pOtherNet = (DEV_NET *)pAC->dev[1 - pNet->NetNr]->priv; + pOtherNet =netdev_priv (pAC->dev[1 - pNet->NetNr]);if ((pOtherNet->Mtu>1500 ) && (NewMtu<=1500 ) && (pOtherNet->Up==1 )) {return (0 ); }
@@ -2847,7 +2845,7 @@*/ static struct net_device_stats *SkGeStats (struct SK_NET_DEVICE *dev) { -DEV_NET *pNet = (DEV_NET *) dev->priv; +DEV_NET *pNet =netdev_priv (dev);SK_AC *pAC = pNet->pAC;SK_PNMI_STRUCT_DATA *pPnmiStruct;/* structure for all Pnmi-Data */ SK_PNMI_STAT *pPnmiStat;/* pointer to virtual XMAC stat. data */
@@ -2945,7 +2943,7 @@SK_DBG_MSG (NULL ,SK_DBGMOD_DRV ,SK_DBGCAT_DRV_ENTRY , ("SkGeIoctl starts now...\n" )); - pNet = (DEV_NET *) dev->priv; + pNet =netdev_priv (dev); pAC = pNet->pAC;if (copy_from_user (&Ioctl, rq->ifr_data,sizeof (SK_GE_IOCTL ))) {
@@ -4531,11 +4529,8 @@int SkDrvEnterDiagMode (SK_AC *pAc)/* pointer to adapter context */ { -SK_AC *pAC =NULL ; -DEV_NET *pNet =NULL ; - - pNet = (DEV_NET *) pAc->dev[0 ]->priv; - pAC = pNet->pAC; +DEV_NET *pNet =netdev_priv (pAc->dev[0 ]); +SK_AC *pAC = pNet->pAC;SK_MEMCPY (&(pAc->PnmiBackup), &(pAc->PnmiStruct),sizeof (SK_PNMI_STRUCT_DATA ));
@@ -4550,8 +4545,8 @@ }else { pAC->WasIfUp[0 ] =SK_FALSE ; } -if (pNet != (DEV_NET *) pAc->dev[1 ]->priv) { - pNet = (DEV_NET *) pAc->dev[1 ]->priv; +if (pNet !=netdev_priv (pAC->dev[1 ])) { + pNet =netdev_priv (pAC->dev[1 ]);if (pNet->Up) { pAC->WasIfUp[1 ] =SK_TRUE ; pAC->DiagFlowCtrl =SK_TRUE ;/* for SkGeClose */
@@ -4897,7 +4892,7 @@ goto out_disable_device; } - pNet = dev->priv; + pNet =netdev_priv (dev); pNet->pAC =kmalloc (sizeof (SK_AC ),GFP_KERNEL );if (!pNet->pAC) { printk(KERN_ERR "Unable to allocate adapter "
@@ -4997,7 +4992,7 @@ } pAC->dev[1 ] = dev; - pNet = dev->priv; + pNet =netdev_priv (dev); pNet->PortNr =1 ; pNet->NetNr =1 ; pNet->pAC = pAC;
@@ -5073,7 +5068,7 @@ static void __devexit skge_remove_one(struct pci_dev *pdev) {struct net_device *dev =pci_get_drvdata (pdev); -DEV_NET *pNet = (DEV_NET *) dev->priv; +DEV_NET *pNet =netdev_priv (dev);SK_AC *pAC = pNet->pAC;int have_second_mac =0 ;
PATCH 1/1 (5/23) sk98: use module_param
In reply to a message not in the archiveUse new format module_param rather than now deprecated MODULE_PARM
drivers/net/sk98lin/skge.c +21 -20
@@ -109,6 +109,7 @@#include "h/skversion.h" #include <linux/module.h> +#include <linux/moduleparam.h> #include <linux/init.h> #include <linux/proc_fs.h>
@@ -358,26 +359,6 @@MODULE_AUTHOR ("Mirko Lindner <[email protected]>" );MODULE_DESCRIPTION ("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver" );MODULE_LICENSE ("GPL" ); -MODULE_PARM(Speed_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(Speed_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(AutoNeg_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(AutoNeg_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(DupCap_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(DupCap_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(FlowCtrl_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(FlowCtrl_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(Role_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(Role_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(ConType, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(PrefPort, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(RlmtMode, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -/* used for interrupt moderation */ -MODULE_PARM(IntsPerSec, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "i"); -MODULE_PARM(Moderation, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(Stats, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(ModerationMask, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -MODULE_PARM(AutoSizing, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s"); -#ifdef LINK_SPEED_A static char *Speed_A[SK_MAX_CARD_PARAM ] =LINK_SPEED ;
@@ -462,6 +443,26 @@static char *ModerationMask[SK_MAX_CARD_PARAM ];static char *AutoSizing[SK_MAX_CARD_PARAM ];static char *Stats[SK_MAX_CARD_PARAM ]; + +module_param_array (Speed_A, charp,NULL ,0 ); +module_param_array (Speed_B, charp,NULL ,0 ); +module_param_array (AutoNeg_A, charp,NULL ,0 ); +module_param_array (AutoNeg_B, charp,NULL ,0 ); +module_param_array (DupCap_A, charp,NULL ,0 ); +module_param_array (DupCap_B, charp,NULL ,0 ); +module_param_array (FlowCtrl_A, charp,NULL ,0 ); +module_param_array (FlowCtrl_B, charp,NULL ,0 ); +module_param_array (Role_A, charp,NULL ,0 ); +module_param_array (Role_B, charp,NULL ,0 ); +module_param_array (ConType, charp,NULL ,0 ); +module_param_array (PrefPort, charp,NULL ,0 ); +module_param_array (RlmtMode, charp,NULL ,0 ); +/* used for interrupt moderation */ +module_param_array (IntsPerSec, int,NULL ,0 ); +module_param_array (Moderation, charp,NULL ,0 ); +module_param_array (Stats, charp,NULL ,0 ); +module_param_array (ModerationMask, charp,NULL ,0 ); +module_param_array (AutoSizing, charp,NULL ,0 );/***************************************************************************** *
PATCH 1/1 (6/23) sk98: add netpoll console support
In reply to a message not in the archiveAdd netpoll console support
From: Michal Schmidt <[email protected]>
drivers/net/sk98lin/skge.c +21 -0
@@ -1125,6 +1125,24 @@return SkIsrRetHandled; }/* SkGeIsrOnePort */ +#ifdef CONFIG_NET_POLL_CONTROLLER +/**************************************************************************** +* +* SkGePollController - polling receive, for netconsole +* +* Description: +* Polling receive - used by netconsole and other diagnostic tools +* to allow network i/o with interrupts disabled. +* +* Returns: N/A +*/ +static void SkGePollController (struct net_device *dev) +{ +disable_irq (dev->irq); +SkGeIsr (dev->irq, dev,NULL ); +enable_irq (dev->irq); +} +#endif /**************************************************************************** *
@@ -4928,6 +4946,9 @@ dev->set_mac_address = &SkGeSetMacAddr; dev->do_ioctl = &SkGeIoctl; dev->change_mtu = &SkGeChangeMtu; +#ifdef CONFIG_NET_POLL_CONTROLLER + dev->poll_controller = &SkGePollController; +#endif dev->flags &= ~IFF_RUNNING ;SET_NETDEV_DEV (dev, &pdev->dev);
PATCH 1/1 (7/23) sk98: basic ethtool support
In reply to a message not in the archiveThe basic stuff comes from the newer code from SysKonnect, but I redid it using ethtool_ops and a cleaner way of doing the stats (from e100)
drivers/net/sk98lin/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_SK98LIN) += sk98lin.o sk98lin-objs := \ skge.o \ + skethtool.o \ skdim.o \ skaddr.o \ skgehwt.o \
drivers/net/sk98lin/skethtool.c new file +330 -0
330 lines not on this page · raw message
drivers/net/sk98lin/skge.c +4 -0
@@ -255,6 +255,7 @@/* global variables *********************************************************/ struct SK_NET_DEVICE *SkGeRootDev =NULL ;static SK_BOOL DoPrintInterfaceChange =SK_TRUE ; +extern struct ethtool_ops SkGeEthtoolOps;/* local variables **********************************************************/ static uintptr_t TxQueueAddr[SK_MAX_MACS ][2 ] = {{0x680 ,0x600 },{0x780 ,0x700 }};
@@ -4951,6 +4952,7 @@#endif dev->flags &= ~IFF_RUNNING ;SET_NETDEV_DEV (dev, &pdev->dev); +SET_ETHTOOL_OPS (dev, &SkGeEthtoolOps);#ifdef SK_ZEROCOPY #ifdef USE_SK_TX_CHECKSUM
@@ -5030,6 +5032,8 @@ dev->do_ioctl = &SkGeIoctl; dev->change_mtu = &SkGeChangeMtu; dev->flags &= ~IFF_RUNNING ; +SET_NETDEV_DEV (dev, &pdev->dev); +SET_ETHTOOL_OPS (dev, &SkGeEthtoolOps);#ifdef SK_ZEROCOPY #ifdef USE_SK_TX_CHECKSUM
Re: [PATCH] (7/23) sk98: basic ethtool support
Quoted 4 lines · Stephen Hemminger
The basic stuff comes from the newer code from SysKonnect, but I redid it using
ethtool_opsand a cleaner way of doing the stats (from e100)
Quoted 12 lines
+/*****************************************************************************
+ *
+ * getSettings - retrieves the current settings of the selected adapter
+ *
+ * Description:
+ * The current configuration of the selected adapter is returned.
+ * This configuration involves a)speed, b)duplex and c)autoneg plus
+ * a number of other variables.
+ *
+ * Returns: always 0
+ *
+ */
Please use normal kernel-doc function documentation.
Quoted 1 line
+static int
getSettings(struct net_device *dev, struct ethtool_cmd *ecmd)
And avoid studlyCaps. Also an sk98lin prefix even on private function helps avoiding nameclashes for the generic names (and in the debugger or oopses)
Review
Quoted 2 lines
(quoted diff) +2
-0+{ + const DEV_NET *pNet = netdev_priv(dev);
please always use struct net_device instead of strange typedefs for it.
Re: [PATCH] (7/23) sk98: basic ethtool support
Quoted 19 lines · Stephen Hemminger
Quoted 4 lines
The basic stuff comes from the newer code from SysKonnect, but I redid it using
ethtool_opsand a cleaner way of doing the stats (from e100)Quoted 13 lines
+/*****************************************************************************
+ *
+ * getSettings - retrieves the current settings of the selected
adapter
+ *
+ * Description:
+ * The current configuration of the selected adapter is returned.
+ * This configuration involves a)speed, b)duplex and c)autoneg plus
+ * a number of other variables.
+ *
+ * Returns: always 0
+ *
+ */
Quoted 1 line
Please use normal kernel-doc function documentation.
That was SysKonnect's format, personally I would rather no comment because this isn't an API for any external usage and is obvious.
Quoted 7 lines
Quoted 3 lines
+static int
getSettings(struct net_device *dev, struct ethtool_cmd *ecmd)And avoid studlyCaps. Also an sk98lin prefix even on private function helps avoiding nameclashes for the generic names (and in the debugger or oopses)
I'll just change them to normal kernel format (ie get_settings). But no, putting prefix's on local obvious functions is a waste.
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+{ + const DEV_NET *pNet = netdev_priv(dev);please always use struct
net_deviceinstead of strange typedefs for it.
DEV_NET is one of their typedef's (for the driver private data). I prefer to change them last after all the other patches. Don't want some files using 'struct s_Devnet' and others using 'DEV_NET', that would be more confusing. Eventually DEV_NET will be replaced by something more descriptive 'struct sk98_port' and AC will be 'struct sk8_board'
PATCH 1/1 (8/23) sk98: ethtool phy support
In reply to a message not in the archiveThe basic stuff comes from the newer code from SysKonnect, but I redid it using a per board timer rather than a global timer.
drivers/net/sk98lin/h/skdrv2nd.h +2 -0
@@ -383,6 +383,8 @@SK_CSUM Csum;/* for checksum module */ SK_RLMT Rlmt;/* for rlmt module */ spinlock_t SlowPathLock;/* Normal IRQ lock */ +struct timer_list BlinkTimer;/* for LED blinking */ +int LedsOn;SK_PNMI_STRUCT_DATA PnmiStruct;/* structure to get all Pnmi-Data */ int RlmtMode;/* link check mode to set */ int RlmtNets;/* Number of nets */
drivers/net/sk98lin/skethtool.c +118 -0
134 lines not on this page · raw message
drivers/net/sk98lin/skge.c +6 -0
@@ -245,6 +245,7 @@extern void SkDimDisplayModerationSettings (SK_AC *pAC);extern void SkDimStartModerationTimer (SK_AC *pAC);extern void SkDimModerate (SK_AC *pAC); +extern void SkGeBlinkTimer (unsigned long data);#ifdef DEBUG static void DumpMsg (struct sk_buff *,char *);
@@ -502,6 +503,11 @@spin_lock_init (&pAC->RxPort[i].RxDesRingLock); }spin_lock_init (&pAC->SlowPathLock); + +/* setup phy_id blink timer */ + pAC->BlinkTimer.function = SkGeBlinkTimer; + pAC->BlinkTimer.data = (unsigned long ) dev; +init_timer (&pAC->BlinkTimer);/* level 0 init common modules here */
PATCH 1/1 (9/23) sk98: ethtool pause param support
In reply to a message not in the archiveThe basic stuff comes from the newer code from SysKonnect, but there code had ugly way to find the PNMI instance. This driver seems full of places where they do unnecessary board/port bookeeping (*sigh*)
drivers/net/sk98lin/skethtool.c +108 -1
@@ -163,6 +163,15 @@return 0 ; } +/* +* MIB infrastructure uses instance value starting at 1 +* based on board and port. +*/ +static inline u32 pnmiInstance (const DEV_NET *pNet) +{ +return 1 + (pNet->pAC->RlmtNets ==2 ) + pNet->PortNr; +} +/***************************************************************************** * * setSettings - configures the settings of a selected adapter
@@ -200,7 +209,7 @@ *buf = (ecmd->duplex ==DUPLEX_FULL ) ?SK_LMODE_AUTOFULL :SK_LMODE_AUTOHALF ; - instance =1 + (pAC->RlmtNets ==2 ) + pNet->PortNr; + instance =pnmiInstance (pNet);if (SkPnmiSetVar (pAC, pAC->IoBase,OID_SKGE_LINK_MODE , &buf, &len, instance, pNet->NetNr) !=SK_PNMI_ERR_OK )return -EINVAL ;
@@ -437,6 +446,102 @@return 0 ; } +/***************************************************************************** +* +* getPauseParams - retrieves the pause parameters +* +* Description: +* All current pause parameters of a selected adapter are placed +* in the passed ethtool_pauseparam structure and are returned. +* +* Returns: N/A +* +*/ +static void getPauseParams (struct net_device *dev,struct ethtool_pauseparam *epause) +{ +DEV_NET *pNet =netdev_priv (dev); +SK_AC *pAC = pNet->pAC; +SK_GEPORT *pPort = &pAC->GIni.GP[pNet->PortNr]; + + epause->rx_pause = (pPort->PFlowCtrlMode ==SK_FLOW_MODE_SYMMETRIC ) || + (pPort->PFlowCtrlMode ==SK_FLOW_MODE_SYM_OR_REM ); + + epause->tx_pause = epause->rx_pause || (pPort->PFlowCtrlMode ==SK_FLOW_MODE_LOC_SEND ); + epause->autoneg = epause->rx_pause || epause->tx_pause; +} + +/***************************************************************************** +* +* setPauseParams - configures the pause parameters of an adapter +* +* Description: +* This function sets the Rx or Tx pause parameters +* +* Returns: +* ==0: everything fine, no error +* !=0: the return value is the error code of the failure +*/ +static int setPauseParams (struct net_device *dev ,struct ethtool_pauseparam *epause) +{ +DEV_NET *pNet =netdev_priv (dev); +SK_AC *pAC = pNet->pAC; +SK_GEPORT *pPort = &pAC->GIni.GP[pNet->PortNr]; +u32 instance =pnmiInstance (pNet); +struct ethtool_pauseparam old; +u8 oldspeed = pPort->PLinkSpeedUsed; +char buf[4 ]; +int len =1 ; +int ret; + +/* +** we have to determine the current settings to see if +** the operator requested any modification of the flow +** control parameters... +*/ +getPauseParams (dev, &old); + +/* +** perform modifications regarding the changes +** requested by the operator +*/ +if (epause->autoneg != old.autoneg) + *buf = epause->autoneg ?SK_FLOW_MODE_NONE :SK_FLOW_MODE_SYMMETRIC ; +else { +if (epause->rx_pause && epause->tx_pause) + *buf =SK_FLOW_MODE_SYMMETRIC ; +else if (epause->rx_pause && !epause->tx_pause) + *buf =SK_FLOW_MODE_SYM_OR_REM ; +else if (!epause->rx_pause && epause->tx_pause) + *buf =SK_FLOW_MODE_LOC_SEND ; +else + *buf =SK_FLOW_MODE_NONE ; + } + + ret =SkPnmiSetVar (pAC, pAC->IoBase,OID_SKGE_FLOWCTRL_MODE , + &buf, &len, instance, pNet->NetNr); + +if (ret !=SK_PNMI_ERR_OK ) { +SK_DBG_MSG (NULL ,SK_DBGMOD_DRV ,SK_DBGCAT_CTRL , + ("ethtool (sk98lin): error changing rx/tx pause (%i)\n" , ret)); + goto err; + } + +/* +** It may be that autoneg has been disabled! Therefore +** set the speed to the previously used value... +*/ +if (!epause->autoneg) { + len =1 ; + ret =SkPnmiSetVar (pAC, pAC->IoBase,OID_SKGE_SPEED_MODE , + &oldspeed, &len, instance, pNet->NetNr); +if (ret !=SK_PNMI_ERR_OK ) +SK_DBG_MSG (NULL ,SK_DBGMOD_DRV ,SK_DBGCAT_CTRL , + ("ethtool (sk98lin): error setting speed (%i)\n" , ret)); + } + err: +return ret ? -EIO :0 ; +} +struct ethtool_ops SkGeEthtoolOps = { .get_settings = getSettings, .set_settings = setSettings,
@@ -445,4 +550,6 @@ .get_stats_count = getStatsCount, .get_ethtool_stats = getEthtoolStats, .phys_id = locateDevice, + .get_pauseparam = getPauseParams, + .set_pauseparam = setPauseParams, };
PATCH 1/1 (10/23) sk98: cleanout unnecessary controller elements
In reply to a message not in the archiveCatchall cleanup patch:
* get rid of obfuscating #define's
* eliminate structure elements in the controller structure that are never used or only used in one context or available in net_device
drivers/net/sk98lin/h/skdrv1st.h +7 -17
@@ -96,9 +96,6 @@#define SK_BIG_ENDIAN #endif -#define SK_NET_DEVICE net_device - -/* we use gethrtime(), return unit: nanoseconds */ #define SK_TICKS_PER_SEC 100
@@ -109,12 +106,11 @@#define SK_MAX_MACS 2#define SK_MAX_NETS 2 -#define SK_IOC char __iomem * - +typedef char __iomem *SK_IOC ;typedef struct s_DrvRlmtMbuf SK_MBUF ; -#define SK_CONST64 INT64_C -#define SK_CONSTU64 UINT64_C +#define SK_CONST64 (x) (x##ll) +#define SK_CONSTU64 (x) (x##ull)#define SK_MEMCPY (dest,src,size) memcpy(dest,src,size)#define SK_MEMCMP (s1,s2,size) memcmp(s1,s2,size)
@@ -143,27 +139,21 @@#define t_uscalar_t unsigned int#define uintptr_t unsigned long -#define __CONCAT__ (A ,B ) A##B +#ifdef DEBUG -#define INT32_C (a) __CONCAT__(a,L) -#define INT64_C (a) __CONCAT__(a,LL) -#define UINT32_C (a) __CONCAT__(a,UL) -#define UINT64_C (a) __CONCAT__(a,ULL) +#define SK_DBG_PRINTF(fmt, arg...) printk(KERN_DEBUG fmt,##arg) -#ifdef DEBUG -#define SK_DBG_PRINTF printk#ifndef SK_DEBUG_CHKMOD #define SK_DEBUG_CHKMOD 0#endif #ifndef SK_DEBUG_CHKCAT #define SK_DEBUG_CHKCAT 0#endif +/* those come from the makefile */ #define SK_DBG_CHKMOD (pAC) (SK_DEBUG_CHKMOD)#define SK_DBG_CHKCAT (pAC) (SK_DEBUG_CHKCAT) -extern void SkDbgPrintf (const char *format,...); -#define SK_DBGMOD_DRV 0x00010000/**** possible driver debug categories ********************************/
@@ -184,7 +174,7 @@#define SK_ERR_LOG SkErrorLog -extern void SkErrorLog (SK_AC *,int ,int ,char *); +extern void SkErrorLog (const SK_AC *,int ,int ,const char *);#endif
drivers/net/sk98lin/h/skdrv2nd.h +3 -24
@@ -266,11 +266,9 @@typedef struct s_DevNet DEV_NET ;struct s_DevNet { +SK_AC *pAC;int PortNr;int NetNr; -int Mtu; -int Up; -SK_AC *pAC; };typedef struct s_TxPort TX_PORT ;
@@ -356,10 +354,6 @@SK_TIMER ModTimer;/* just some timer */ }; -typedef struct s_PerStrm PER_STRM ; - -#define SK_ALLOC_IRQ 0x00000001 -#ifdef SK_DIAG_SUPPORT #define DIAG_ACTIVE 1#define DIAG_NOTACTIVE 0
@@ -390,31 +384,17 @@SK_IOC IoBase;/* register set of adapter */ int BoardLevel;/* level of active hw init (0-2) */ -char DeviceStr[80 ];/* adapter string from vpd */ -SK_U32 AllocFlag;/* flag allocation of resources */ struct pci_dev *PciDev;/* for access to pci config space */ -SK_U32 PciDevId;/* pci device id */ -struct SK_NET_DEVICE *dev[2 ];/* pointer to device struct */ -char Name[30 ];/* driver name */ +struct net_device *dev[2 ];/* pointer to device struct */ int RxBufSize;/* length of receive buffers */ struct net_device_stats stats;/* linux 'netstat -i' statistics */ int Index;/* internal board index number */ /* adapter RAM sizes for queues of active port */ -int RxQueueSize;/* memory used for receive queue */ -int TxSQueueSize;/* memory used for sync. tx queue */ -int TxAQueueSize;/* memory used for async. tx queue */ - -int PromiscCount;/* promiscuous mode counter */ -int AllMultiCount;/* allmulticast mode counter */ -int MulticCount;/* number of different MC */ -/* addresses for this board */ -/* (may be more than HW can)*/ -int HWRevision;/* Hardware revision */ int ActivePort;/* the active XMAC port */ -int MaxPorts;/* number of activated ports */ +int MaxPorts;/* number of activated ports */ int TxDescrPerRing;/* # of descriptors per tx ring */ int RxDescrPerRing;/* # of descriptors per rx ring */
@@ -434,7 +414,6 @@DIM_INFO DynIrqModInfo;/* all data related to DIM */ /* Only for tests */ -int PortUp;int PortDown;int ChipsetType;/* Chipset family type * 0 == Genesis family support
drivers/net/sk98lin/skge.c +85 -138
529 lines not on this page · raw message
Jeff Garzik
AppliedRe: [PATCH] (10/23) sk98: cleanout unnecessary controller elements
Quoted 5 lines · Stephen Hemminger
Catchall cleanup patch:
* get rid of obfuscating #define's
* eliminate structure elements in the controller structure that are never used or only used in one context or available innet_device
I applied patches 1 - 9 to netdev-2.6 queue.
I would prefer that you split up this patch a bit more, and resend that (and the rest of this series) in a new patch series.
Jeff
PATCH 1/1 (12/23) sk98: add module version
In reply to a message not in the archiveAdd MODULE_VERSION to build process
drivers/net/sk98lin/skge.c +1 -0
@@ -350,6 +350,7 @@MODULE_AUTHOR ("Mirko Lindner <[email protected]>" );MODULE_DESCRIPTION ("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver" );MODULE_LICENSE ("GPL" ); +MODULE_VERSION (VER_STRING );#ifdef LINK_SPEED_A static char *Speed_A[SK_MAX_CARD_PARAM ] =LINK_SPEED ;
PATCH 1/1 (11/23) sk98: board counter incremented twice
In reply to a message not in the archiveMinor bug, bourd found incremented twice. Also don't need to initialize fields already zerod.
drivers/net/sk98lin/skge.c +0 -5
@@ -4972,11 +4972,6 @@ }#endif - pNet->PortNr =0 ; - pNet->NetNr =0 ; - - boards_found++; -/* More then one port found */ if ((pAC->GIni.GIMacsFound ==2 ) && (pAC->RlmtNets ==2 )) {if ((dev =alloc_etherdev (sizeof (DEV_NET ))) ==0 ) {
PATCH 1/1 (13/23) sk98: handle ring full correctly
In reply to a message not in the archiveThis driver needs to manage it's transmit queue properly. The hard_start_xmit needs to return OK if send successfully and BUSY (1) if queue is full. In either case must free skb, existing code would leak if tx ring filled!
Also, check if queue is send fills queue and stop transmit queue as needed. In order to test for ring full w/o race, pull locking up from XmitFrame to SkGeXmit
drivers/net/sk98lin/skge.c +26 -64
@@ -1396,59 +1396,43 @@* Returns: * 0, if everything is ok * !=0, on error -* WARNING: returning 1 in 'tbusy' case caused system crashes (double -* allocated skb's) !!! */ static int SkGeXmit (struct sk_buff *skb,struct net_device *dev) { -DEV_NET *pNet; -SK_AC *pAC; -int Rc;/* return code of XmitFrame */ - - pNet =netdev_priv (dev); - pAC = pNet->pAC; +DEV_NET *pNet =netdev_priv (dev); +SK_AC *pAC = pNet->pAC; +TX_PORT *pTxPort; +int rc; +unsigned long flags; + +if (pAC->RlmtNets ==2 ) + pTxPort = &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW ]; +else + pTxPort = &pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW ]; +spin_lock_irqsave (&pTxPort->TxDesRingLock, flags);if ((!skb_shinfo (skb)->nr_frags) || (pAC->GIni.GIChipId ==CHIP_ID_GENESIS )) {/* Don't activate scatter-gather and hardware checksum */ - -if (pAC->RlmtNets ==2 ) - Rc =XmitFrame ( - pAC, - &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW ], - skb); -else - Rc =XmitFrame ( - pAC, - &pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW ], - skb); + rc =XmitFrame ( pAC, pTxPort, skb); }else { -/* scatter-gather and hardware TCP checksumming anabled*/ -if (pAC->RlmtNets ==2 ) - Rc =XmitFrameSG ( - pAC, - &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW ], - skb); -else - Rc =XmitFrameSG ( - pAC, - &pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW ], - skb); + rc =XmitFrameSG (pAC, pTxPort, skb); } -/* Transmitter out of resources? */ -if (Rc <=0 ) { +/* No space left for next transmit */ +if (rc <=0 )netif_stop_queue (dev); - } -/* If not taken, give buffer ownership back to the -* queueing layer. -*/ -if (Rc <0 ) -return (1 ); +spin_unlock_irqrestore (&pTxPort->TxDesRingLock, flags); - dev->trans_start = jiffies; -return (0 ); +/* Transmit failed, out of resources */ +if (rc <0 ) { +dev_kfree_skb (skb); +return NETDEV_TX_BUSY ; + }else { + dev->trans_start = jiffies; +return NETDEV_TX_OK ; + } }/* SkGeXmit */
@@ -1481,7 +1465,6 @@ {TXD *pTxd;/* the rxd to fill */ TXD *pOldTxd; -unsigned long Flags;SK_U64 PhysAddr;int Protocol;int IpHeaderLength;
@@ -1489,7 +1472,6 @@SK_DBG_MSG (NULL ,SK_DBGMOD_DRV ,SK_DBGCAT_DRV_TX_PROGRESS , ("X" )); -spin_lock_irqsave (&pTxPort->TxDesRingLock, Flags);#ifndef USE_TX_COMPLETE FreeTxDescriptors (pAC, pTxPort);#endif
@@ -1500,7 +1482,6 @@*/ FreeTxDescriptors (pAC, pTxPort);if (pTxPort->TxdRingFree ==0 ) { -spin_unlock_irqrestore (&pTxPort->TxDesRingLock, Flags);SK_PNMI_CNT_NO_TX_BUF (pAC, pTxPort->PortIndex); SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
@@ -1523,7 +1504,6 @@*/ if (BytesSend <C_LEN_ETHERNET_MINSIZE ) {if ((pMessage =skb_padto (pMessage,C_LEN_ETHERNET_MINSIZE )) ==NULL ) { -spin_unlock_irqrestore (&pTxPort->TxDesRingLock, Flags);return 0 ; } pMessage->len =C_LEN_ETHERNET_MINSIZE ;
@@ -1598,16 +1578,7 @@SK_OUT8 (pTxPort->HwAddr,Q_CSR ,CSR_START ); } -/* -** after releasing the lock, the skb may immediately be free'd -*/ -spin_unlock_irqrestore (&pTxPort->TxDesRingLock, Flags); -if (pTxPort->TxdRingFree !=0 ) { -return (BytesSend); - }else { -return (0 ); - } - +return (pTxPort->TxdRingFree !=0 ); }/* XmitFrame */ /*****************************************************************************
@@ -1640,16 +1611,13 @@int Protocol;skb_frag_t *sk_frag;SK_U64 PhysAddr; -unsigned long Flags; -spin_lock_irqsave (&pTxPort->TxDesRingLock, Flags);#ifndef USE_TX_COMPLETE FreeTxDescriptors (pAC, pTxPort);#endif if ((skb_shinfo (pMessage)->nr_frags +1 ) > pTxPort->TxdRingFree) {FreeTxDescriptors (pAC, pTxPort);if ((skb_shinfo (pMessage)->nr_frags +1 ) > pTxPort->TxdRingFree) { -spin_unlock_irqrestore (&pTxPort->TxDesRingLock, Flags);SK_PNMI_CNT_NO_TX_BUF (pAC, pTxPort->PortIndex); SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
@@ -1781,13 +1749,7 @@ pTxPort->pTxdRingPrev = pTxdLst; pTxPort->pTxdRingHead = pTxd; -spin_unlock_irqrestore (&pTxPort->TxDesRingLock, Flags); - -if (pTxPort->TxdRingFree >0 ) { -return (BytesSend); - }else { -return (0 ); - } +return (pTxPort->TxdRingFree >0 ); }/*****************************************************************************
Re: [PATCH] (13/23) sk98: handle ring full correctly
Quoted 4 lines · Stephen Hemminger
This driver needs to manage it's transmit queue properly. The
hard_start_xmitneeds to return OK if send successfully and BUSY (1) if queue is full. In either case must free skb, existing code would leak if tx ring filled!
This isn't true. When returning NETDEV_TX_BUSY, the caller will requeue or drop the skb. So
drivers/net/sk98lin/skge.c line 1435
Quoted 8 lines
drivers/net/sk98lin/skge.c +8
-0+/* Transmit failed, out of resources */ +if (rc <0 ) { +dev_kfree_skb (skb); +return NETDEV_TX_BUSY ; + }else { + dev->trans_start = jiffies; +return NETDEV_TX_OK ; + }
it shouldn't be freed here.
-Tommy
PATCH 1/1 (15/23) sk98: rearrange initialization
In reply to a message not in the archiveThe code in the latest SysKonnect driver is arranged differently, this aligns the two versions to allow for easier comparisons. Also:
Don't enable the pci device twice.
Add common SkGeDevInit for common code used to setup both ports
drivers/net/sk98lin/skge.c +295 -254
@@ -111,6 +111,7 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/init.h> +#include <linux/ethtool.h> #include <linux/proc_fs.h> #include "h/skdrv1st.h"
@@ -179,8 +180,11 @@* ******************************************************************************/ +static int sk98lin_init_device (struct pci_dev *pdev,const struct pci_device_id *ent); +static void sk98lin_remove_device (struct pci_dev *pdev);static void FreeResources (struct net_device *dev);static int SkGeBoardInit (struct net_device *dev,SK_AC *pAC); +static void SkGeDevInit (struct net_device *dev,struct pci_dev *pdev);static SK_BOOL BoardAllocMem (SK_AC *pAC);static void BoardFreeMem (SK_AC *pAC);static void BoardInitMem (SK_AC *pAC);
@@ -251,6 +255,7 @@extern void SkDimStartModerationTimer (SK_AC *pAC);extern void SkDimModerate (SK_AC *pAC);extern void SkGeBlinkTimer (unsigned long data); +extern struct ethtool_ops SkGeEthtoolOps;#ifdef DEBUG static void DumpMsg (struct sk_buff *,char *);
@@ -260,12 +265,237 @@/* global variables *********************************************************/ static SK_BOOL DoPrintInterfaceChange =SK_TRUE ; -extern struct ethtool_ops SkGeEthtoolOps; +static const char *BootString =BOOT_STRING ;/* local variables **********************************************************/ static uintptr_t TxQueueAddr[SK_MAX_MACS ][2 ] = {{0x680 ,0x600 },{0x780 ,0x700 }};static uintptr_t RxQueueAddr[SK_MAX_MACS ] = {0x400 ,0x480 }; + +static struct pci_device_id sk98lin_pci_tbl[] = { + {PCI_VENDOR_ID_3COM ,0x1700 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_3COM ,0x80eb ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_SYSKONNECT ,0x4300 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_SYSKONNECT ,0x4320 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_DLINK ,0x4c00 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_MARVELL ,0x4320 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, +#if 0 /* don't handle Yukon2 cards at the moment -- [email protected] */ + {PCI_VENDOR_ID_MARVELL ,0x4360 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_MARVELL ,0x4361 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, +#endif + {PCI_VENDOR_ID_MARVELL ,0x5005 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_CNET ,0x434e ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_LINKSYS ,0x1032 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_LINKSYS ,0x1064 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {0 , } +}; + +static struct pci_driver skge_driver = { + .name =DRIVER_FILE_NAME , + .id_table = sk98lin_pci_tbl, + .probe = sk98lin_init_device, + .remove =__devexit_p (sk98lin_remove_device), +}; + +/***************************************************************************** +* +* sk98lin_init_device - initialize the adapter +* +* Description: +* This function initializes the adapter. Resources for +* the adapter are allocated and the adapter is brought into Init 1 +* state. +* +* Returns: +* 0, if everything is ok +* !=0, on error +*/ +static int __devinit sk98lin_init_device (struct pci_dev *pdev, +const struct pci_device_id *ent) +{ +SK_AC *pAC; +DEV_NET *pNet =NULL ; +struct net_device *dev =NULL ; +static int boards_found =0 ; +int error = -ENODEV ; + + error =pci_enable_device (pdev); +if (error) { +printk (KERN_ERR "sk98lin: cannot enable PCI device, aborting\n" ); + goto out; + } + +/* Configure DMA attributes. */ +if ((error =pci_set_dma_mask (pdev, (u64 )0xffffffffffffffffULL )) || + (error =pci_set_dma_mask (pdev, (u64 )0xffffffff ))) { +printk (KERN_ERR "sk98lin: cannot set PCI dma mask\n" ); + goto out_disable_device; + } + +/* Allocate both structures for first port, +and only one for second port. */ + dev =alloc_etherdev (sizeof (DEV_NET )); +if (!dev) { +printk (KERN_ERR "sk98lin: unable to allocate etherdev structure!\n" ); + error = -ENOMEM ; + goto out_disable_device; + } + + pNet =netdev_priv (dev); + pNet->pAC =kmalloc (sizeof (SK_AC ),GFP_KERNEL ); +if (pNet->pAC ==NULL ){ +printk (KERN_ERR "sk98lin: unable to allocate adapter structure!\n" ); + error = -ENOMEM ; + goto out_free_netdev; + } + +if (BootString) { +printk ("%s\n" , BootString); + BootString =NULL ; + } + +memset (pNet->pAC,0 ,sizeof (SK_AC )); + pAC = pNet->pAC; + pAC->PciDev = pdev; + pAC->dev[0 ] = dev; + pAC->dev[1 ] = dev; + pAC->CheckQueue =SK_FALSE ; + + dev->irq = pdev->irq; + +strcpy (dev->name,pci_name (pdev));/* use PCI for early messages */ + error =SkGeInitPCI (pAC); +if (error) { +printk ("SKGE: PCI setup failed: %i\n" , error); + goto out_free_adapter; + } + +SkGeDevInit (dev, pdev); + + pAC->Index = boards_found++; + +if (SkGeBoardInit (dev, pAC)) + goto out_free_adapter; + +#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 ; +#endif +#endif + +/* Register net device */ +strcpy (dev->name,"eth%d" ); +if (register_netdev (dev)) { +printk (KERN_ERR "SKGE: Could not register device.\n" ); + goto out_free_resources; + } + +SkGeProcCreate (dev); + +/* Print adapter specific string from vpd */ +PrintProductStr (dev->name, pAC); + +/* 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 ); + +memcpy (&dev->dev_addr, &pAC->Addr.Net[0 ].CurrentMacAddress,6 ); + +/* 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" ); + goto out; + } + + pAC->dev[1 ] = dev; + pNet =netdev_priv (dev); + pNet->PortNr =1 ; + pNet->NetNr =1 ; + pNet->pAC = pAC; + +memcpy (&dev->dev_addr, + &pAC->Addr.Net[1 ].CurrentMacAddress,6 ); + +SkGeDevInit (dev, pdev); + +#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 ; +#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 { +SkGeProcCreate (dev); +PrintProductStr (dev->name, pAC); +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 ; + +memset (&pAC->PnmiBackup,0 ,sizeof (SK_PNMI_STRUCT_DATA )); +memcpy (&pAC->PnmiBackup, &pAC->PnmiStruct,sizeof (SK_PNMI_STRUCT_DATA )); + +pci_set_drvdata (pdev, dev); +return 0 ; + + out_free_resources: +FreeResources (dev); + out_free_adapter: +kfree (pAC); + out_free_netdev: +free_netdev (dev); + out_disable_device: +pci_disable_device (pdev); + out: +return error; +} + +static void SkGeDevInit (struct net_device *dev,struct pci_dev *pdev) +{ +SET_MODULE_OWNER (dev); + dev->open = &SkGeOpen; + dev->stop = &SkGeClose; + dev->hard_start_xmit = &SkGeXmit; + dev->get_stats = &SkGeStats; + dev->set_multicast_list = &SkGeSetRxMode; + dev->set_mac_address = &SkGeSetMacAddr; + dev->do_ioctl = &SkGeIoctl; + dev->change_mtu = &SkGeChangeMtu; +#ifdef CONFIG_NET_POLL_CONTROLLER + dev->poll_controller = &SkGePollController; +#endif +SET_ETHTOOL_OPS (dev, &SkGeEthtoolOps); +SET_NETDEV_DEV (dev, &pdev->dev); +} + +/***************************************************************************** * * SkGeInitPCI - Init the PCI resources
@@ -276,16 +506,12 @@* Returns: N/A * */ -int SkGeInitPCI (SK_AC *pAC) +static int SkGeInitPCI (SK_AC *pAC) {struct net_device *dev = pAC->dev[0 ];struct pci_dev *pdev = pAC->PciDev;int retval; -if (pci_enable_device (pdev) !=0 ) { -return 1 ; - } - dev->mem_start =pci_resource_start (pdev,0 );pci_set_master (pdev);
@@ -326,7 +552,6 @@return retval; } -/***************************************************************************** * * FreeResources - release resources allocated for adapter
@@ -462,6 +687,69 @@/***************************************************************************** * +* sk98lin_remove_device - device deinit function +* +* Description: +* Disable adapter if it is still running, free resources, +* free device struct. +* +* Returns: N/A +*/ +static void __devexit sk98lin_remove_device(struct pci_dev *pdev) +{ +struct net_device *dev =pci_get_drvdata (pdev); +DEV_NET *pNet =netdev_priv (dev); +SK_AC *pAC = pNet->pAC; +struct net_device *dev1 = pAC->dev[1 ]; + +if (dev1 != dev) { +unregister_netdev (dev1); +SkGeProcRemove (dev1); + } + +SkGeProcRemove (dev); +unregister_netdev (dev); + +SkGeYellowLED (pAC, pAC->IoBase,0 ); + +if (pAC->BoardLevel ==SK_INIT_RUN ) { +SK_EVPARA EvPara; +unsigned long Flags; + +/* 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 ; + } + +FreeResources (dev); + +if (dev1 != dev) +free_netdev (dev1); +free_netdev (dev); +pci_disable_device (pdev); +pci_set_drvdata (pdev,NULL ); +} + +/***************************************************************************** +* * SkGeBoardInit - do level 0 and 1 initialization * * Description:
@@ -4821,253 +5109,6 @@#endif -static int __devinit skge_probe_one (struct pci_dev *pdev, -const struct pci_device_id *ent) -{ -SK_AC *pAC; -DEV_NET *pNet =NULL ; -struct net_device *dev =NULL ; -static int boards_found =0 ; -int error = -ENODEV ; - -if (pci_enable_device (pdev)) - goto out; - -/* Configure DMA attributes. */ -if (pci_set_dma_mask (pdev, (u64 )0xffffffffffffffffULL ) && -pci_set_dma_mask (pdev, (u64 )0xffffffff )) - goto out_disable_device; - - -if ((dev =alloc_etherdev (sizeof (DEV_NET ))) ==NULL ) { -printk (KERN_ERR "Unable to allocate etherdev " -"structure!\n" ); - goto out_disable_device; - } - - pNet =netdev_priv (dev); - pNet->pAC =kmalloc (sizeof (SK_AC ),GFP_KERNEL ); -if (!pNet->pAC) { -printk (KERN_ERR "Unable to allocate adapter " -"structure!\n" ); - goto out_free_netdev; - } - -memset (pNet->pAC,0 ,sizeof (SK_AC )); - pAC = pNet->pAC; - pAC->PciDev = pdev; - pAC->dev[0 ] = dev; - pAC->dev[1 ] = dev; - pAC->CheckQueue =SK_FALSE ; - - dev->irq = pdev->irq; - error =SkGeInitPCI (pAC); -if (error) { -printk ("SKGE: PCI setup failed: %i\n" , error); - goto out_free_netdev; - } - -SET_MODULE_OWNER (dev); - dev->open = &SkGeOpen; - dev->stop = &SkGeClose; - dev->hard_start_xmit = &SkGeXmit; - dev->get_stats = &SkGeStats; - dev->set_multicast_list = &SkGeSetRxMode; - dev->set_mac_address = &SkGeSetMacAddr; - dev->do_ioctl = &SkGeIoctl; - dev->change_mtu = &SkGeChangeMtu; -#ifdef CONFIG_NET_POLL_CONTROLLER - dev->poll_controller = &SkGePollController; -#endif - dev->flags &= ~IFF_RUNNING ; -SET_NETDEV_DEV (dev, &pdev->dev); -SET_ETHTOOL_OPS (dev, &SkGeEthtoolOps); - -#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 ; - } -#endif -#endif - - pAC->Index = boards_found++; - -if (SkGeBoardInit (dev, pAC)) - goto out_free_netdev; - -/* Register net device */ -if (register_netdev (dev)) { -printk (KERN_ERR "SKGE: Could not register device.\n" ); - goto out_free_resources; - } - -/* Print adapter specific string from vpd */ -PrintProductStr (dev->name, pAC); - -/* 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 ); - - -memcpy (&dev->dev_addr, &pAC->Addr.Net[0 ].CurrentMacAddress,6 ); - -SkGeProcCreate (dev); - -/* 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" ); - goto out; - } - - pAC->dev[1 ] = dev; - pNet =netdev_priv (dev); - pNet->PortNr =1 ; - pNet->NetNr =1 ; - pNet->pAC = pAC; - - dev->open = &SkGeOpen; - dev->stop = &SkGeClose; - dev->hard_start_xmit = &SkGeXmit; - dev->get_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_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 ; - } -#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 { -SkGeProcCreate (dev); -memcpy (&dev->dev_addr, - &pAC->Addr.Net[1 ].CurrentMacAddress,6 ); - -PrintProductStr (dev->name, pAC); -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 ; - -memset (&pAC->PnmiBackup,0 ,sizeof (SK_PNMI_STRUCT_DATA )); -memcpy (&pAC->PnmiBackup, &pAC->PnmiStruct,sizeof (SK_PNMI_STRUCT_DATA )); - -pci_set_drvdata (pdev, dev); -return 0 ; - - out_free_resources: -FreeResources (dev); - out_free_netdev: -free_netdev (dev); - out_disable_device: -pci_disable_device (pdev); - out: -return error; -} - -static void __devexit skge_remove_one(struct pci_dev *pdev) -{ -struct net_device *dev =pci_get_drvdata (pdev); -DEV_NET *pNet =netdev_priv (dev); -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 ); - -if (pAC->BoardLevel ==SK_INIT_RUN ) { -SK_EVPARA EvPara; -unsigned long Flags; - -/* 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 ; - } - -FreeResources (dev); -free_netdev (dev); -if (otherdev != dev) -free_netdev (otherdev); -kfree (pAC); -} - -static struct pci_device_id skge_pci_tbl[] = { - {PCI_VENDOR_ID_3COM ,0x1700 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_3COM ,0x80eb ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_SYSKONNECT ,0x4300 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_SYSKONNECT ,0x4320 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_DLINK ,0x4c00 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_MARVELL ,0x4320 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, -#if 0 /* don't handle Yukon2 cards at the moment -- [email protected] */ - {PCI_VENDOR_ID_MARVELL ,0x4360 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_MARVELL ,0x4361 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, -#endif - {PCI_VENDOR_ID_MARVELL ,0x5005 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_CNET ,0x434e ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_LINKSYS ,0x1032 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_LINKSYS ,0x1064 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {0 , } -}; - -static struct pci_driver skge_driver = { - .name ="skge" , - .id_table = skge_pci_tbl, - .probe = skge_probe_one, - .remove =__devexit_p (skge_remove_one), -};static int __init skge_init (void ) {
Re: [PATCH] (15/23) sk98: rearrange initialization
Quoted 5 lines · Stephen Hemminger
The code in the latest SysKonnect driver is arranged differently, this aligns the two versions to allow for easier comparisons. Also:
Don't enable the pci device twice.
Add common SkGeDevInit for common code used to setup both ports
please don't reorder the functions. I placed them in natural order when converting to new pci probing for a good reason.
Re: [PATCH] (15/23) sk98: rearrange initialization
Quoted 9 lines · Stephen Hemminger
Quoted 5 lines
The code in the latest SysKonnect driver is arranged differently, this aligns the two versions to allow for easier comparisons. Also:
Don't enable the pci device twice.
Add common SkGeDevInit for common code used to setup both portsplease don't reorder the functions. I placed them in natural order when converting to new pci probing for a good reason.
I really don't care which way it goes, just trying to make SysKonnect's life easeier. When all the comments are in, I will redo the patches without the reordering
PATCH 1/1 (14/23) sk98: don't obfuscate irqreturn_t
In reply to a message not in the archiveDont redefine irqreturn_t and dev_kfree anymore. It probably was done for compatiablity with 2.4 but we are past that point now.
drivers/net/sk98lin/skge.c +29 -39
@@ -166,22 +166,12 @@// #define CON_TYPE {"Auto", } // #define RLMT_MODE {"CheckLinkState", } -#define DEV_KFREE_SKB (skb) dev_kfree_skb(skb) -#define DEV_KFREE_SKB_IRQ (skb) dev_kfree_skb_irq(skb) -#define DEV_KFREE_SKB_ANY (skb) dev_kfree_skb_any(skb) - -/* Set blink mode*/ #define OEM_CONFIG_VALUE ( SK_ACT_LED_BLINK | \ SK_DUP_LED_NORMAL | \ SK_LED_LINK100_ON) -/* Isr return value */ -#define SkIsrRetVar irqreturn_t -#define SkIsrRetNone IRQ_NONE -#define SkIsrRetHandled IRQ_HANDLED -/******************************************************************************* *
@@ -195,8 +185,8 @@static void BoardFreeMem (SK_AC *pAC);static void BoardInitMem (SK_AC *pAC);static void SetupRing (SK_AC *,void *,uintptr_t ,RXD **,RXD **,RXD **,int *,SK_BOOL ); -static SkIsrRetVar SkGeIsr (int irq,void *dev_id,struct pt_regs *ptregs); -static SkIsrRetVar SkGeIsrOnePort (int irq,void *dev_id,struct pt_regs *ptregs); +static irqreturn_t SkGeIsr (int irq,void *dev_id,struct pt_regs *ptregs); +static irqreturn_t SkGeIsrOnePort (int irq,void *dev_id,struct pt_regs *ptregs);static int SkGeOpen (struct net_device *dev);static int SkGeClose (struct net_device *dev);static int SkGeXmit (struct sk_buff *skb,struct net_device *dev);
@@ -895,7 +885,7 @@* Returns: N/A * */ -static SkIsrRetVar SkGeIsr (int irq,void *dev_id,struct pt_regs *ptregs) +static irqreturn_t SkGeIsr (int irq,void *dev_id,struct pt_regs *ptregs) {struct net_device *dev = (struct net_device *)dev_id;DEV_NET *pNet;
@@ -909,8 +899,8 @@* Check and process if its our interrupt */ SK_IN32 (pAC->IoBase,B0_SP_ISRC , &IntSrc); -if (IntSrc ==0 ) { -return SkIsrRetNone; +if (IntSrc ==0 || IntSrc == ~0 ) { +return IRQ_NONE ; }while (((IntSrc &IRQ_MASK ) & ~SPECIAL_IRQS ) !=0 ) {
@@ -1027,7 +1017,7 @@/* IRQ is processed - Enable IRQs again*/ SK_OUT32 (pAC->IoBase,B0_IMSK , pAC->GIni.GIValIrqMask); -return SkIsrRetHandled; +return IRQ_HANDLED ; }/* SkGeIsr */
@@ -1044,12 +1034,12 @@* Returns: N/A * */ -static SkIsrRetVar SkGeIsrOnePort (int irq,void *dev_id,struct pt_regs *ptregs) +static irqreturn_t SkGeIsrOnePort (int irq,void *dev_id,struct pt_regs *ptregs) { -struct net_device *dev = (struct net_device *)dev_id; -DEV_NET *pNet; -SK_AC *pAC; -SK_U32 IntSrc;/* interrupts source register contents */ +struct net_device *dev = (struct net_device *)dev_id; +DEV_NET *pNet; +SK_AC *pAC; +SK_U32 IntSrc;/* interrupts source register contents */ pNet =netdev_priv (dev); pAC = pNet->pAC;
@@ -1058,30 +1048,30 @@* Check and process if its our interrupt */ SK_IN32 (pAC->IoBase,B0_SP_ISRC , &IntSrc); -if (IntSrc ==0 ) { -return SkIsrRetNone; +if (IntSrc ==0 || IntSrc == ~0 ) { +return IRQ_NONE ; }while (((IntSrc &IRQ_MASK ) & ~SPECIAL_IRQS ) !=0 ) {#if 0 /* software irq currently not used */ if (IntSrc &IS_IRQ_SW ) {SK_DBG_MSG (NULL ,SK_DBGMOD_DRV , -SK_DBGCAT_DRV_INT_SRC , - ("Software IRQ\n" )); +SK_DBGCAT_DRV_INT_SRC , + ("Software IRQ\n" )); }#endif if (IntSrc &IS_R1_F ) {SK_DBG_MSG (NULL ,SK_DBGMOD_DRV , -SK_DBGCAT_DRV_INT_SRC , - ("EOF RX1 IRQ\n" )); +SK_DBGCAT_DRV_INT_SRC , + ("EOF RX1 IRQ\n" ));ReceiveIrq (pAC, &pAC->RxPort[0 ],SK_TRUE );SK_PNMI_CNT_RX_INTR (pAC,0 ); }#ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */ if (IntSrc &IS_XA1_F ) {SK_DBG_MSG (NULL ,SK_DBGMOD_DRV , -SK_DBGCAT_DRV_INT_SRC , - ("EOF AS TX1 IRQ\n" )); +SK_DBGCAT_DRV_INT_SRC , + ("EOF AS TX1 IRQ\n" ));SK_PNMI_CNT_TX_INTR (pAC,0 );spin_lock (&pAC->TxPort[0 ][TX_PRIO_LOW ].TxDesRingLock);FreeTxDescriptors (pAC, &pAC->TxPort[0 ][TX_PRIO_LOW ]);
@@ -1132,13 +1122,13 @@* SkGeDrvEvent(), because it is timer * guarded now * -ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE); -*/ +ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE); +*/ /* IRQ is processed - Enable IRQs again*/ SK_OUT32 (pAC->IoBase,B0_IMSK , pAC->GIni.GIValIrqMask); -return SkIsrRetHandled; +return IRQ_HANDLED ; }/* SkGeIsrOnePort */ #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1837,7 +1827,7 @@ PCI_DMA_TODEVICE);if (Control &BMU_EOF ) -DEV_KFREE_SKB_ANY (pTxd->pMBuf);/* free message */ +dev_kfree_skb_any (pTxd->pMBuf);/* free message */ pTxPort->TxdRingFree++; pTxd->TBControl &= ~BMU_SW ;
@@ -2267,7 +2257,7 @@SK_DBG_MSG (NULL ,SK_DBGMOD_DRV ,SK_DBGCAT_DRV_RX_PROGRESS , ("D" )); -DEV_KFREE_SKB (pMsg); +dev_kfree_skb (pMsg); } }/* if not for rlmt */
@@ -2316,7 +2306,7 @@ pAC->dev[pRxPort->PortIndex]->last_rx = jiffies; }else { -DEV_KFREE_SKB (pMsg); +dev_kfree_skb (pMsg); } }/* if packet for rlmt */
@@ -2343,7 +2333,7 @@ PhysAddr, pAC->RxBufSize -2 , PCI_DMA_FROMDEVICE); -DEV_KFREE_SKB_IRQ (pRxd->pMBuf); +dev_kfree_skb_irq (pRxd->pMBuf); pRxd->pMBuf =NULL ; pRxPort->RxdRingFree++; pRxPort->pRxdRingHead = pRxd->pNextRxd;
@@ -2426,7 +2416,7 @@ PhysAddr, pAC->RxBufSize -2 , PCI_DMA_FROMDEVICE); -DEV_KFREE_SKB (pRxd->pMBuf); +dev_kfree_skb (pRxd->pMBuf); pRxd->pMBuf =NULL ; } pRxd->RBControl &=BMU_OWN ;
@@ -3935,7 +3925,7 @@ pFreeMbuf = pMbuf;do { pNextMbuf = pFreeMbuf->pNext; -DEV_KFREE_SKB_ANY (pFreeMbuf->pOs); +dev_kfree_skb_any (pFreeMbuf->pOs); pFreeMbuf = pNextMbuf; }while ( pFreeMbuf !=NULL ); }/* SkDrvFreeRlmtMbuf */
@@ -4406,7 +4396,7 @@if (XmitFrame (pAC, &pAC->TxPort[pRlmtMbuf->PortIdx][TX_PRIO_LOW ], pMsg) <0 ) -DEV_KFREE_SKB_ANY (pMsg); +dev_kfree_skb_any (pMsg);break ;case SK_DRV_TIMER :if (Param.Para32[0 ] ==SK_DRV_MODERATION_TIMER ) {
PATCH 1/1 (16/23) sk98: more efficient time OsGetTime
In reply to a message not in the archiveAvoid doing a gettimeofday to only get low resolution time. Can use jiffies_64 and internal 64 bit divide to get what is needed.
drivers/net/sk98lin/h/skdrv1st.h +0 -3
@@ -96,9 +96,6 @@#define SK_BIG_ENDIAN #endif -/* we use gethrtime(), return unit: nanoseconds */ -#define SK_TICKS_PER_SEC 100 -#define SK_MEM_MAPPED_IO // #define SK_RLMT_SLOW_LOOKAHEAD
drivers/net/sk98lin/h/skdrv2nd.h +18 -16
@@ -56,7 +56,6 @@extern SK_MBUF *SkDrvAllocRlmtMbuf (SK_AC *,SK_IOC ,unsigned );extern void SkDrvFreeRlmtMbuf (SK_AC *,SK_IOC ,SK_MBUF *); -extern SK_U64 SkOsGetTime (SK_AC *);extern int SkPciReadCfgDWord (SK_AC *,int ,SK_U32 *);extern int SkPciReadCfgWord (SK_AC *,int ,SK_U16 *);extern int SkPciReadCfgByte (SK_AC *,int ,SK_U8 *);
@@ -83,25 +82,28 @@ }; -/* -* Time macros -*/ -#if SK_TICKS_PER_SEC ==100 -#define SK_PNMI_HUNDREDS_SEC (t) (t) +/* Units used for timing measurements. */ +#define SK_TICKS_PER_SEC HZ + +/* OS time value in HZ (1000 or 100) */ +static inline SK_U64 SkOsGetTime (const SK_AC *pAC) +{ +return get_jiffies_64 (); +} + +/* Convert OS time units to hundredth's of sec */ +static inline SK_U64 jiffies_64_to_hsecs (u64 t) +{ +#if (HZ %100 ) ==0 +do_div (t,HZ /100 );#else -#define SK_PNMI_HUNDREDS_SEC (t) ((((unsigned long)t) * 100) / \ - (SK_TICKS_PER_SEC)) + t *=100 ; +do_div (x,HZ );#endif - -/* -* New SkOsGetTime -*/ -#define SkOsGetTimeCurrent (pAC, pUsec) {\ - struct timeval t;\ - do_gettimeofday(&t);\ - *pUsec = ((((t.tv_sec) * 1000000L)+t.tv_usec)/10000);\ +return t; } +#define SK_PNMI_HUNDREDS_SEC (t) jiffies_64_to_hsecs(t)/* * ioctl definitions
drivers/net/sk98lin/skge.c +0 -20
@@ -4221,26 +4221,6 @@/***************************************************************************** * -* SkOsGetTime - provide a time value -* -* Description: -* This routine provides a time value. The unit is 1/HZ (defined by Linux). -* It is not used for absolute time, but only for time differences. -* -* -* Returns: -* Time value -*/ -SK_U64 SkOsGetTime (SK_AC *pAC) -{ -SK_U64 PrivateJiffies; -SkOsGetTimeCurrent (pAC, &PrivateJiffies); -return PrivateJiffies; -}/* SkOsGetTime */ - - -/***************************************************************************** -* * SkPciReadCfgDWord - read a 32 bit value from pci config space * * Description:
PATCH 1/1 (17/23) sk98: use lockless transmit
In reply to a message not in the archiveThis driver lends it self to the new lockless transmit hook in 2.6. Also, flag that driver can do 64 bit DMA, if it is successful in setting the bigger mask.
drivers/net/sk98lin/skge.c +19 -6
@@ -323,6 +323,7 @@DEV_NET *pNet =NULL ;struct net_device *dev =NULL ;static int boards_found =0 ; +int pci_using_dac =0 ;int error = -ENODEV ; error =pci_enable_device (pdev);
@@ -332,8 +333,9 @@ }/* Configure DMA attributes. */ -if ((error =pci_set_dma_mask (pdev, (u64 )0xffffffffffffffffULL )) || - (error =pci_set_dma_mask (pdev, (u64 )0xffffffff ))) { +if (!(error =pci_set_dma_mask (pdev,DMA_64BIT_MASK ))) + pci_using_dac =1 ; +else if ((error =pci_set_dma_mask (pdev,DMA_32BIT_MASK ))) {printk (KERN_ERR "sk98lin: cannot set PCI dma mask\n" ); goto out_disable_device; }
@@ -375,6 +377,8 @@ }SkGeDevInit (dev, pdev); +if (pci_using_dac) + dev->features |=NETIF_F_HIGHDMA ; pAC->Index = boards_found++;
@@ -438,6 +442,9 @@SkGeDevInit (dev, pdev); +if (pci_using_dac) + dev->features |=NETIF_F_HIGHDMA ; +#ifdef SK_ZEROCOPY #ifdef USE_SK_TX_CHECKSUM if (pAC->ChipsetType)
@@ -447,7 +454,6 @@#endif #endif -if (register_netdev (dev)) {printk (KERN_ERR "SKGE: Could not register device.\n" );free_netdev (dev);
@@ -501,9 +507,10 @@#endif SET_ETHTOOL_OPS (dev, &SkGeEthtoolOps);SET_NETDEV_DEV (dev, &pdev->dev); -} - + dev->flags &= ~IFF_RUNNING ; + dev->features |=NETIF_F_LLTX ; +}/***************************************************************************** * * SkGeInitPCI - Init the PCI resources
@@ -1707,7 +1714,13 @@else pTxPort = &pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW ]; -spin_lock_irqsave (&pTxPort->TxDesRingLock, flags); +local_irq_save (flags); +if (!spin_trylock (&pTxPort->TxDesRingLock)) { +/* Collision - tell upper layer to requeue */ +local_irq_restore (flags); +return NETDEV_TX_LOCKED ; + } +if ((!skb_shinfo (skb)->nr_frags) || (pAC->GIni.GIChipId ==CHIP_ID_GENESIS )) {/* Don't activate scatter-gather and hardware checksum */
PATCH 1/1 (20/23) sk98: checksum ethtool and improvements
In reply to a message not in the archiveThe driver was going through a lot of work to use portable code for receive checksum offload. On Linux it much simpler, and all that code can be eliminated.
Make transmit/receive checksum controllable by ethtool.
drivers/net/sk98lin/Makefile +7 -4
@@ -26,9 +26,11 @@ skrlmt.o \ sktimer.o \ skvpd.o \ - skxmac2.o \ - skproc.o \ - skcsum.o + skxmac2.o + +ifdef CONFIG_PROC_FS +sk98lin-objs += skproc.o +endif # DBGDEF = \ # -DDEBUG
@@ -77,7 +79,8 @@ # SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources # SK_DBGCAT_DRV_EVENT 0x08000000 driver events -EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT -DSK_USE_CSUM -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM) +EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT \ + -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM) clean: rm -f core *.o *.a *.s
drivers/net/sk98lin/h/skcsum.h +2 -2
@@ -155,11 +155,11 @@* s_Csum - The CSUM module context structure. */ typedef struct s_Csum { +#ifdef SK_USE_CSUM /* Enabled receive SK_PROTO_XXX bit flags. */ unsigned ReceiveFlags[SK_MAX_NETS]; -#ifdef TX_CSUM unsigned TransmitFlags[SK_MAX_NETS]; -#endif /* TX_CSUM */ +#endif /* The protocol statistics structure; one per supported protocol. */ SKCS_PROTO_STATS ProtoStats[SK_MAX_NETS][SKCS_NUM_PROTOCOLS];
drivers/net/sk98lin/h/skdrv2nd.h +8 -4
@@ -200,6 +200,13 @@#define C_PROTO_ID_UDP 17/* refer to RFC 790 or Stevens' */ #define C_PROTO_ID_TCP 6/* TCP/IP illustrated for details */ +/* +** Hardware supports receive checksumming starting at two offsets +** Linux only uses the first one (skip ether header). +*/ +#define SK_CHECKSUM_OFFSET_1 ETH_HLEN +#define SK_CHECKSUM_OFFSET_2 (ETH_HLEN + 20) +/* TX and RX descriptors *****************************************************/ typedef struct s_RxD RXD ;/* the receive descriptor */
@@ -302,6 +309,7 @@int RxFillLimit;/* limit for buffers in ring */ SK_IOC HwAddr;/* bmu registers address */ int PortIndex;/* index number of port (0 or 1) */ +SK_BOOL UseRxCsum;/* use Rx checksumming (yes/no) */ };/* Definitions needed for interrupt moderation *******************************/
@@ -410,10 +418,6 @@/* the port structures with descriptor rings */ TX_PORT TxPort[SK_MAX_MACS ][2 ];RX_PORT RxPort[SK_MAX_MACS ]; - -unsigned int CsOfs1;/* for checksum calculation */ -unsigned int CsOfs2;/* for checksum calculation */ -SK_U32 CsOfs;/* for checksum calculation */ SK_BOOL CheckQueue;/* check event queue soon */ SK_TIMER DrvCleanupTimer;/* to check for pending descriptors */
drivers/net/sk98lin/skcsum.c deleted +0 -871
871 lines not on this page · raw message
drivers/net/sk98lin/skethtool.c +87 -0
100 lines not on this page · raw message
drivers/net/sk98lin/skge.c +32 -97
221 lines not on this page · raw message
PATCH 1/1 (19/23) sk98: more cleanups
In reply to a message not in the archiveMake sure and set flags on both ports correctly. Set address before register_netdev so if any protocols want to pickup mac address they see correct value.
Fix memory leak on remove (my bad from patch 15).
drivers/net/sk98lin/skge.c +22 -36
@@ -184,7 +184,8 @@static void sk98lin_remove_device (struct pci_dev *pdev);static void FreeResources (struct net_device *dev);static int SkGeBoardInit (struct net_device *dev,SK_AC *pAC); -static void SkGeDevInit (struct net_device *dev,struct pci_dev *pdev); +static void SkGeDevInit (struct net_device *dev,struct pci_dev *pdev, +const SK_AC *pAC);static SK_BOOL BoardAllocMem (SK_AC *pAC);static void BoardFreeMem (SK_AC *pAC);static void BoardInitMem (SK_AC *pAC);
@@ -338,7 +339,6 @@DEV_NET *pNet =NULL ;struct net_device *dev =NULL ;static int boards_found =0 ; -int pci_using_dac =0 ;int error = -ENODEV ; error =pci_enable_device (pdev);
@@ -348,9 +348,8 @@ }/* Configure DMA attributes. */ -if (!(error =pci_set_dma_mask (pdev,DMA_64BIT_MASK ))) - pci_using_dac =1 ; -else if ((error =pci_set_dma_mask (pdev,DMA_32BIT_MASK ))) { +if ((error =pci_set_dma_mask (pdev,DMA_64BIT_MASK )) && + (error =pci_set_dma_mask (pdev,DMA_32BIT_MASK ))) {printk (KERN_ERR "sk98lin: cannot set PCI dma mask\n" ); goto out_disable_device; }
@@ -393,23 +392,12 @@ goto out_free_adapter; } -SkGeDevInit (dev, pdev); -if (pci_using_dac) - dev->features |=NETIF_F_HIGHDMA ; - pAC->Index = boards_found++;if (SkGeBoardInit (dev, pAC)) - goto out_free_adapter; + goto out_free_resources; -#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 ; -#endif -#endif +SkGeDevInit (dev, pdev, pAC);/* Register net device */ strcpy (dev->name,"eth%d" );
@@ -419,6 +407,7 @@ }SkGeProcCreate (dev); +memcpy (&dev->dev_addr, &pAC->Addr.Net[0 ].CurrentMacAddress,6 );/* Print adapter specific string from vpd */ PrintProductStr (dev->name, pAC);
@@ -434,8 +423,6 @@SkGeYellowLED (pAC, pAC->IoBase,1 ); -memcpy (&dev->dev_addr, &pAC->Addr.Net[0 ].CurrentMacAddress,6 ); -/* More then one port found */ if ((pAC->GIni.GIMacsFound ==2 ) && (pAC->RlmtNets ==2 )) {if ((dev =alloc_etherdev (sizeof (DEV_NET ))) ==0 ) {
@@ -450,22 +437,9 @@ pNet->NetNr =1 ; pNet->pAC = pAC; -memcpy (&dev->dev_addr, - &pAC->Addr.Net[1 ].CurrentMacAddress,6 ); - -SkGeDevInit (dev, pdev); +memcpy (&dev->dev_addr, &pAC->Addr.Net[1 ].CurrentMacAddress,6 ); -if (pci_using_dac) - dev->features |=NETIF_F_HIGHDMA ; - -#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 ; -#endif -#endif +SkGeDevInit (dev, pdev, pAC);if (register_netdev (dev)) {printk (KERN_ERR "SKGE: Could not register device.\n" );
@@ -504,7 +478,8 @@return error; } -static void SkGeDevInit (struct net_device *dev,struct pci_dev *pdev) +static void SkGeDevInit (struct net_device *dev,struct pci_dev *pdev, +const SK_AC *pAC) {SET_MODULE_OWNER (dev); dev->open = &SkGeOpen;
@@ -523,6 +498,16 @@ dev->flags &= ~IFF_RUNNING ; dev->features |=NETIF_F_LLTX ; + +if (pdev->dma_mask ==DMA_64BIT_MASK ) + dev->features |=NETIF_F_HIGHDMA ; + +if (pAC->GIni.GIChipId !=CHIP_ID_GENESIS ) { + dev->features |=NETIF_F_SG ; +#ifdef USE_SK_TX_CHECKSUM + dev->features |=NETIF_F_IP_CSUM ; +#endif + } }/***************************************************************************** *
@@ -768,6 +753,7 @@ }FreeResources (dev); +kfree (pAC);if (dev1 != dev)free_netdev (dev1);
PATCH 1/1 (18/23) sk98: update pci_id table
In reply to a message not in the archiveReformat and update pci id table. Add values from lastest SysKonnect driver, and use pci_id defines if available.
drivers/net/sk98lin/skge.c +36 -15
@@ -277,24 +277,45 @@static uintptr_t TxQueueAddr[SK_MAX_MACS ][2 ] = {{0x680 ,0x600 },{0x780 ,0x700 }};static uintptr_t RxQueueAddr[SK_MAX_MACS ] = {0x400 ,0x480 }; - -static struct pci_device_id sk98lin_pci_tbl[] = { - {PCI_VENDOR_ID_3COM ,0x1700 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_3COM ,0x80eb ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_SYSKONNECT ,0x4300 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_SYSKONNECT ,0x4320 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_DLINK ,0x4c00 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_MARVELL ,0x4320 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, +static struct pci_device_id sk98lin_pci_tbl[]__devinitdata = { + {PCI_VENDOR_ID_3COM ,PCI_DEVICE_ID_3COM_3C940 , +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_3COM ,PCI_DEVICE_ID_3COM_3C940B , +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_SYSKONNECT ,PCI_DEVICE_ID_SYSKONNECT_GE , +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_SYSKONNECT ,PCI_DEVICE_ID_SYSKONNECT_YU , +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_SYSKONNECT ,0x9E00 ,/* SK-9Exx 10/100/1000Base-T Adapter */ +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_DLINK ,PCI_DEVICE_ID_DLINK_DGE510T , +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_MARVELL ,0x4320 ,/* Gigabit Ethernet Controller */ +PCI_ANY_ID ,PCI_ANY_ID }, #if 0 /* don't handle Yukon2 cards at the moment -- [email protected] */ - {PCI_VENDOR_ID_MARVELL ,0x4360 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_MARVELL ,0x4361 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_MARVELL ,0x4350 ,/* Fast Ethernet Controller */ +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_MARVELL ,0x4351 ,/* Fast Ethernet Controller */ +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_MARVELL ,0x4360 ,/* Gigabit Ethernet Controller */ +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_MARVELL ,0x4361 ,/* Gigabit Ethernet Controller */ +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_MARVELL ,0x4362 ,/* Gigabit Ethernet Controller */ +PCI_ANY_ID ,PCI_ANY_ID }, #endif - {PCI_VENDOR_ID_MARVELL ,0x5005 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_CNET ,0x434e ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_LINKSYS ,0x1032 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_LINKSYS ,0x1064 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {0 , } + {PCI_VENDOR_ID_MARVELL ,0x5005 ,/* Marvell (11ab), Belkin */ +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_CNET ,PCI_DEVICE_ID_CNET_GIGACARD , +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_LINKSYS ,PCI_DEVICE_ID_LINKSYS_EG1032 , +PCI_ANY_ID ,PCI_ANY_ID }, + {PCI_VENDOR_ID_LINKSYS ,PCI_DEVICE_ID_LINKSYS_EG1064 , +PCI_ANY_ID ,PCI_ANY_ID }, + {0 } }; + +MODULE_DEVICE_TABLE (pci, sk98lin_pci_tbl);static struct pci_driver skge_driver = { .name =DRIVER_FILE_NAME ,
PATCH 1/1 (21/23) sk98: transmit ring barriers
In reply to a message not in the archiveTransmit descriptor control doesn't need to be volatile, it is much better to use explicit memory barriers. This generates better code and makes sure that ordering is maintained. When doing SG figure out the bits once rather than for each frag.
drivers/net/sk98lin/h/skdrv2nd.h +1 -1
@@ -227,7 +227,7 @@typedef struct s_TxD TXD ;/* the transmit descriptor */ struct s_TxD { -volatile SK_U32 TBControl;/* Transmit Buffer Control */ +SK_U32 TBControl;/* Transmit Buffer Control */ SK_U32 VNextTxd;/* Next transmit descriptor,low dword */ SK_U32 VDataLow;/* Transmit Buffer Addr, low dword */ SK_U32 VDataHigh;/* Transmit Buffer Addr, high dword */
drivers/net/sk98lin/skge.c +38 -59
200 lines not on this page · raw message
PATCH 1/1 (22/23) sk98: diag code changes
In reply to a message not in the archiveCleanup DIAG support code.
* Use type safe structure assignment rather than memcpy
* PCI device number is available in pci_dev don't need to go string parsing to find it.
* Compile correctly if SK_DIAG_SUPPORT not defined
drivers/net/sk98lin/h/skdrv2nd.h +0 -2
@@ -364,10 +364,8 @@SK_TIMER ModTimer;/* just some timer */ }; -#ifdef SK_DIAG_SUPPORT #define DIAG_ACTIVE 1#define DIAG_NOTACTIVE 0 -#endif /**************************************************************************** * Per board structure / Adapter Context structure:
drivers/net/sk98lin/skge.c +11 -71
148 lines not on this page · raw message
drivers/net/sk98lin/skproc.c +1 -1
@@ -76,7 +76,7 @@ Size =SK_PNMI_STRUCT_SIZE ;#ifdef SK_DIAG_SUPPORT if (pAC->BoardLevel ==SK_INIT_DATA ) { -SK_MEMCPY (&(pAC->PnmiStruct), &(pAC->PnmiBackup),sizeof (SK_PNMI_STRUCT_DATA )); + pAC->PnmiStruct = pAC->PnmiBackup;if (pAC->DiagModeActive ==DIAG_NOTACTIVE ) { pAC->Pnmi.DiagAttached =SK_DIAG_IDLE ; }
PATCH 1/1 (23/23) sk98: eliminate large controller scratch pad elements
In reply to a message not in the archiveGet rid of 44K of space in the driver structure which was just being used as a scratch pad when making the calls to read stats. PnmiStruct can just be kmalloc'd/kfree in those cases.
PNMI initialization can be done in one place using existing macro's for consistency
Don't need to cast and mask when converting u64 to u32.
drivers/net/sk98lin/h/skdrv2nd.h +3 -4
@@ -385,9 +385,9 @@spinlock_t SlowPathLock;/* Normal IRQ lock */ struct timer_list BlinkTimer;/* for LED blinking */ int LedsOn; -SK_PNMI_STRUCT_DATA PnmiStruct;/* structure to get all Pnmi-Data */ -int RlmtMode;/* link check mode to set */ -int RlmtNets;/* Number of nets */ + +int RlmtMode;/* link check mode to set */ +int RlmtNets;/* Number of nets */ SK_IOC IoBase;/* register set of adapter */ int BoardLevel;/* level of active hw init (0-2) */
@@ -425,7 +425,6 @@#ifdef SK_DIAG_SUPPORT SK_U32 DiagModeActive;/* is diag active? */ SK_BOOL DiagFlowCtrl;/* for control purposes */ -SK_PNMI_STRUCT_DATA PnmiBackup;/* backup structure for all Pnmi-Data */ SK_BOOL WasIfUp[SK_MAX_MACS ];/* for OpenClose while * DIAG is busy with NIC */
drivers/net/sk98lin/skethtool.c +20 -3
@@ -297,9 +297,26 @@static void getEthtoolStats (struct net_device *dev,struct ethtool_stats *stats,u64 *data) { -const DEV_NET *pNet =netdev_priv (dev); -const SK_AC *pAC = pNet->pAC; -const SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct; +DEV_NET *pNet =netdev_priv (dev); +SK_AC *pAC = pNet->pAC; +unsigned long flags; +unsigned int size; +int err; +SK_PNMI_STRUCT_DATA *pPnmiStruct; + + + pPnmiStruct =kmalloc (sizeof (*pPnmiStruct),GFP_KERNEL ); +if (!pPnmiStruct) +return ; + +memset (pPnmiStruct,0 ,sizeof (*pPnmiStruct)); + size =sizeof (*pPnmiStruct); +spin_lock_irqsave (&pAC->SlowPathLock, flags); + err =SkPnmiGetStruct (pAC, pAC->IoBase, pPnmiStruct, &size, pNet->NetNr); +spin_unlock_irqrestore (&pAC->SlowPathLock, flags); + +if (err) +return ; *data++ = pPnmiStruct->Stat[0 ].StatRxOkCts; *data++ = pPnmiStruct->Stat[0 ].StatTxOkCts;
drivers/net/sk98lin/skge.c +77 -97
304 lines not on this page · raw message
drivers/net/sk98lin/skproc.c +8 -14
@@ -60,33 +60,26 @@struct net_device *dev = seq->private;DEV_NET *pNet =netdev_priv (dev);SK_AC *pAC = pNet->pAC; -SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct; +SK_PNMI_STRUCT_DATA *pPnmiStruct;unsigned long Flags;unsigned int Size;char sens_msg[50 ];int t;int i; + pPnmiStruct =kmalloc (sizeof (*pPnmiStruct),GFP_KERNEL ); +if (!pPnmiStruct) +return -ENOMEM ; +/* NetIndex in GetStruct is now required, zero is only dummy */ for (t=pAC->GIni.GIMacsFound; t >0 ; t--) {if ((pAC->GIni.GIMacsFound ==2 ) && pAC->RlmtNets ==1 ) t--; +memset (pPnmiStruct,0 ,sizeof (*pPnmiStruct));spin_lock_irqsave (&pAC->SlowPathLock, Flags); Size =SK_PNMI_STRUCT_SIZE ; -#ifdef SK_DIAG_SUPPORT -if (pAC->BoardLevel ==SK_INIT_DATA ) { - pAC->PnmiStruct = pAC->PnmiBackup; -if (pAC->DiagModeActive ==DIAG_NOTACTIVE ) { - pAC->Pnmi.DiagAttached =SK_DIAG_IDLE ; - } - }else { -SkPnmiGetStruct (pAC, pAC->IoBase, pPnmiStruct, &Size, t-1 ); - } -#else -SkPnmiGetStruct (pAC, pAC->IoBase, - pPnmiStruct, &Size, t-1 ); -#endif +SkPnmiGetStruct (pAC, pAC->IoBase, pPnmiStruct, &Size, t-1 );spin_unlock_irqrestore (&pAC->SlowPathLock, Flags);if (pAC->dev[t-1 ] == dev) {
@@ -240,6 +233,7 @@ } } +kfree (pPnmiStruct);return 0 ; }
PATCH 1/1 (0/23) sk98 driver fixes and enhancements
In reply to Michael HeyseThis is the first set of patches to merge some of the new SysKonnect code with existing 2.6 driver and fix several bugs.
1: Remove explicit module refcounting (bug)
2: Make OnesHash table local constant.
3: proc print interface cleanup
4: Use netdev_priv
5: Use module_param_array instead of deprecated MODULE_PARM
6: Add netpoll controller support
7: Basic ethtool support
8: Ethtool support for LED blinking
9: Ethtool pause param support
10: Cleanup
11: Fix boards_found count
12: Add MODULE_VERSION
13: Handle ring full condition properly (bug)
14: Get rid of obfuscation irqreturn_t
15: Rearrange functions to match SysKonnect code
16: More efficient OsGetTime
17: Enable high dma and lockless transmit
18: reorganize pci_device table
19: Do initialization better
20: Ethtool tx & receive checksum efficiently
21: Tx ring management improvements
22: Cleanup the code under DIAG_SUPPORT
23: Eliminate Pnmi scratchpad common
To spare people's mailbox the individual patches won't go to LKML just to netdev.
Re: [PATCH] (0/23) sk98 driver fixes and enhancements
Quoted 2 lines · Stephen Hemminger
This is the first set of patches to merge some of the new SysKonnect code with existing 2.6 driver and fix several bugs.
So I was wrong and it did *not* take very long ;-) Thanks!
Michael
Re: [PATCH] (0/23) sk98 driver fixes and enhancements
Quoted 8 lines · On Fri, 12 Nov 2004 01:17:10 +0100 Michael Heyse <[email protected]> wrote:
Quoted 2 lines · Stephen Hemminger
This is the first set of patches to merge some of the new SysKonnect code with existing 2.6 driver and fix several bugs.
So I was wrong and it did *not* take very long ;-) Thanks!
Michael
Still missing stuff from the SysKonnect version:
* Yukon2 support because existing SysKonnect code is too ugly as it is. Next week I should have a de-mucked version.
* NAPI code in their version is broken under stress and needs work.
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 (1/23) sk98: no explicit module ref counting needed
Network driver's shouldn't be doing module reference counting on 2.6. This is a bad replication of 2.4 behaviour
drivers/net/sk98lin/skge.c +3 -31
@@ -1166,10 +1166,6 @@ }#endif -if (!try_module_get (THIS_MODULE )) { -return (-1 );/* increase of usage count not possible */ - } -/* Set blink mode */ if ((pAC->PciDev->vendor ==0x1186 ) || (pAC->PciDev->vendor ==0x11ab )) pAC->GIni.GILedBlinkCtrl =OEM_CONFIG_VALUE ;
@@ -1177,7 +1173,6 @@if (pAC->BoardLevel ==SK_INIT_DATA ) {/* level 1 init common modules here */ if (SkGeInit (pAC, pAC->IoBase,SK_INIT_IO ) !=0 ) { -module_put (THIS_MODULE );/* decrease usage count */ printk ("%s: HWInit (1) failed.\n" , pAC->dev[pNet->PortNr]->name);return (-1 ); }
@@ -1193,7 +1188,6 @@if (pAC->BoardLevel !=SK_INIT_RUN ) {/* tschilling: Level 2 init modules here, check return value. */ if (SkGeInit (pAC, pAC->IoBase,SK_INIT_RUN ) !=0 ) { -module_put (THIS_MODULE );/* decrease usage count */ printk ("%s: HWInit (2) failed.\n" , pAC->dev[pNet->PortNr]->name);return (-1 ); }
@@ -1285,7 +1279,6 @@#ifdef SK_DIAG_SUPPORT if (pAC->DiagModeActive ==DIAG_ACTIVE ) {if (pAC->DiagFlowCtrl ==SK_FALSE ) { -module_put (THIS_MODULE );/* ** notify that the interface which has been closed ** by operator interaction must not be started up
@@ -1376,7 +1369,6 @@ pAC->MaxPorts--; pNet->Up =0 ; -module_put (THIS_MODULE );return (0 ); }/* SkGeClose */
@@ -4681,20 +4673,11 @@ dev = pAC->dev[devNbr]; -/* -** Function SkGeClose() uses MOD_DEC_USE_COUNT (2.2/2.4) -** or module_put() (2.6) to decrease the number of users for -** a device, but if a device is to be put under control of -** the DIAG, that count is OK already and does not need to -** be adapted! Hence the opposite MOD_INC_USE_COUNT or -** try_module_get() needs to be used again to correct that. +/* On Linux 2.6 the network driver does NOT mess with reference +** counts. The driver MUST be able to be unloaded at any time +** due to the possibility of hotplug. */ -if (!try_module_get (THIS_MODULE )) { -return (-1 ); - } -if (SkGeClose (dev) !=0 ) { -module_put (THIS_MODULE );return (-1 ); }return (0 );
@@ -4723,17 +4706,6 @@if (SkGeOpen (dev) !=0 ) {return (-1 ); - }else { -/* -** Function SkGeOpen() uses MOD_INC_USE_COUNT (2.2/2.4) -** or try_module_get() (2.6) to increase the number of -** users for a device, but if a device was just under -** control of the DIAG, that count is OK already and -** does not need to be adapted! Hence the opposite -** MOD_DEC_USE_COUNT or module_put() needs to be used -** again to correct that. -*/ -module_put (THIS_MODULE ); }/*
Re: [PATCH] (1/23) sk98: no explicit module ref counting needed
Thanks Stephen. We'll check the functionality and let you know as soon as possible.
Mirko
Quoted 2 lines · Stephen Hemminger
Network driver's shouldn't be doing module reference counting on 2.6. This is a bad replication of 2.4 behaviour