skfddi.c 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279
  1. /*
  2. * File Name:
  3. * skfddi.c
  4. *
  5. * Copyright Information:
  6. * Copyright SysKonnect 1998,1999.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * The information in this file is provided "AS IS" without warranty.
  14. *
  15. * Abstract:
  16. * A Linux device driver supporting the SysKonnect FDDI PCI controller
  17. * familie.
  18. *
  19. * Maintainers:
  20. * CG Christoph Goos (cgoos@syskonnect.de)
  21. *
  22. * Contributors:
  23. * DM David S. Miller
  24. *
  25. * Address all question to:
  26. * linux@syskonnect.de
  27. *
  28. * The technical manual for the adapters is available from SysKonnect's
  29. * web pages: www.syskonnect.com
  30. * Goto "Support" and search Knowledge Base for "manual".
  31. *
  32. * Driver Architecture:
  33. * The driver architecture is based on the DEC FDDI driver by
  34. * Lawrence V. Stefani and several ethernet drivers.
  35. * I also used an existing Windows NT miniport driver.
  36. * All hardware dependent fuctions are handled by the SysKonnect
  37. * Hardware Module.
  38. * The only headerfiles that are directly related to this source
  39. * are skfddi.c, h/types.h, h/osdef1st.h, h/targetos.h.
  40. * The others belong to the SysKonnect FDDI Hardware Module and
  41. * should better not be changed.
  42. *
  43. * Modification History:
  44. * Date Name Description
  45. * 02-Mar-98 CG Created.
  46. *
  47. * 10-Mar-99 CG Support for 2.2.x added.
  48. * 25-Mar-99 CG Corrected IRQ routing for SMP (APIC)
  49. * 26-Oct-99 CG Fixed compilation error on 2.2.13
  50. * 12-Nov-99 CG Source code release
  51. * 22-Nov-99 CG Included in kernel source.
  52. * 07-May-00 DM 64 bit fixes, new dma interface
  53. * 31-Jul-03 DB Audit copy_*_user in skfp_ioctl
  54. * Daniele Bellucci <bellucda@tiscali.it>
  55. * 03-Dec-03 SH Convert to PCI device model
  56. *
  57. * Compilation options (-Dxxx):
  58. * DRIVERDEBUG print lots of messages to log file
  59. * DUMPPACKETS print received/transmitted packets to logfile
  60. *
  61. * Tested cpu architectures:
  62. * - i386
  63. * - sparc64
  64. */
  65. /* Version information string - should be updated prior to */
  66. /* each new release!!! */
  67. #define VERSION "2.07"
  68. static const char * const boot_msg =
  69. "SysKonnect FDDI PCI Adapter driver v" VERSION " for\n"
  70. " SK-55xx/SK-58xx adapters (SK-NET FDDI-FP/UP/LP)";
  71. /* Include files */
  72. #include <linux/module.h>
  73. #include <linux/kernel.h>
  74. #include <linux/errno.h>
  75. #include <linux/ioport.h>
  76. #include <linux/slab.h>
  77. #include <linux/interrupt.h>
  78. #include <linux/pci.h>
  79. #include <linux/netdevice.h>
  80. #include <linux/fddidevice.h>
  81. #include <linux/skbuff.h>
  82. #include <linux/bitops.h>
  83. #include <asm/byteorder.h>
  84. #include <asm/io.h>
  85. #include <asm/uaccess.h>
  86. #include "h/types.h"
  87. #undef ADDR // undo Linux definition
  88. #include "h/skfbi.h"
  89. #include "h/fddi.h"
  90. #include "h/smc.h"
  91. #include "h/smtstate.h"
  92. // Define module-wide (static) routines
  93. static int skfp_driver_init(struct net_device *dev);
  94. static int skfp_open(struct net_device *dev);
  95. static int skfp_close(struct net_device *dev);
  96. static irqreturn_t skfp_interrupt(int irq, void *dev_id);
  97. static struct net_device_stats *skfp_ctl_get_stats(struct net_device *dev);
  98. static void skfp_ctl_set_multicast_list(struct net_device *dev);
  99. static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev);
  100. static int skfp_ctl_set_mac_address(struct net_device *dev, void *addr);
  101. static int skfp_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
  102. static netdev_tx_t skfp_send_pkt(struct sk_buff *skb,
  103. struct net_device *dev);
  104. static void send_queued_packets(struct s_smc *smc);
  105. static void CheckSourceAddress(unsigned char *frame, unsigned char *hw_addr);
  106. static void ResetAdapter(struct s_smc *smc);
  107. // Functions needed by the hardware module
  108. void *mac_drv_get_space(struct s_smc *smc, u_int size);
  109. void *mac_drv_get_desc_mem(struct s_smc *smc, u_int size);
  110. unsigned long mac_drv_virt2phys(struct s_smc *smc, void *virt);
  111. unsigned long dma_master(struct s_smc *smc, void *virt, int len, int flag);
  112. void dma_complete(struct s_smc *smc, volatile union s_fp_descr *descr,
  113. int flag);
  114. void mac_drv_tx_complete(struct s_smc *smc, volatile struct s_smt_fp_txd *txd);
  115. void llc_restart_tx(struct s_smc *smc);
  116. void mac_drv_rx_complete(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
  117. int frag_count, int len);
  118. void mac_drv_requeue_rxd(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
  119. int frag_count);
  120. void mac_drv_fill_rxd(struct s_smc *smc);
  121. void mac_drv_clear_rxd(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
  122. int frag_count);
  123. int mac_drv_rx_init(struct s_smc *smc, int len, int fc, char *look_ahead,
  124. int la_len);
  125. void dump_data(unsigned char *Data, int length);
  126. // External functions from the hardware module
  127. extern u_int mac_drv_check_space(void);
  128. extern int mac_drv_init(struct s_smc *smc);
  129. extern void hwm_tx_frag(struct s_smc *smc, char far * virt, u_long phys,
  130. int len, int frame_status);
  131. extern int hwm_tx_init(struct s_smc *smc, u_char fc, int frag_count,
  132. int frame_len, int frame_status);
  133. extern void fddi_isr(struct s_smc *smc);
  134. extern void hwm_rx_frag(struct s_smc *smc, char far * virt, u_long phys,
  135. int len, int frame_status);
  136. extern void mac_drv_rx_mode(struct s_smc *smc, int mode);
  137. extern void mac_drv_clear_rx_queue(struct s_smc *smc);
  138. extern void enable_tx_irq(struct s_smc *smc, u_short queue);
  139. static struct pci_device_id skfddi_pci_tbl[] = {
  140. { PCI_VENDOR_ID_SK, PCI_DEVICE_ID_SK_FP, PCI_ANY_ID, PCI_ANY_ID, },
  141. { } /* Terminating entry */
  142. };
  143. MODULE_DEVICE_TABLE(pci, skfddi_pci_tbl);
  144. MODULE_LICENSE("GPL");
  145. MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
  146. // Define module-wide (static) variables
  147. static int num_boards; /* total number of adapters configured */
  148. static const struct net_device_ops skfp_netdev_ops = {
  149. .ndo_open = skfp_open,
  150. .ndo_stop = skfp_close,
  151. .ndo_start_xmit = skfp_send_pkt,
  152. .ndo_get_stats = skfp_ctl_get_stats,
  153. .ndo_change_mtu = fddi_change_mtu,
  154. .ndo_set_multicast_list = skfp_ctl_set_multicast_list,
  155. .ndo_set_mac_address = skfp_ctl_set_mac_address,
  156. .ndo_do_ioctl = skfp_ioctl,
  157. };
  158. /*
  159. * =================
  160. * = skfp_init_one =
  161. * =================
  162. *
  163. * Overview:
  164. * Probes for supported FDDI PCI controllers
  165. *
  166. * Returns:
  167. * Condition code
  168. *
  169. * Arguments:
  170. * pdev - pointer to PCI device information
  171. *
  172. * Functional Description:
  173. * This is now called by PCI driver registration process
  174. * for each board found.
  175. *
  176. * Return Codes:
  177. * 0 - This device (fddi0, fddi1, etc) configured successfully
  178. * -ENODEV - No devices present, or no SysKonnect FDDI PCI device
  179. * present for this device name
  180. *
  181. *
  182. * Side Effects:
  183. * Device structures for FDDI adapters (fddi0, fddi1, etc) are
  184. * initialized and the board resources are read and stored in
  185. * the device structure.
  186. */
  187. static int skfp_init_one(struct pci_dev *pdev,
  188. const struct pci_device_id *ent)
  189. {
  190. struct net_device *dev;
  191. struct s_smc *smc; /* board pointer */
  192. void __iomem *mem;
  193. int err;
  194. pr_debug(KERN_INFO "entering skfp_init_one\n");
  195. if (num_boards == 0)
  196. printk("%s\n", boot_msg);
  197. err = pci_enable_device(pdev);
  198. if (err)
  199. return err;
  200. err = pci_request_regions(pdev, "skfddi");
  201. if (err)
  202. goto err_out1;
  203. pci_set_master(pdev);
  204. #ifdef MEM_MAPPED_IO
  205. if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
  206. printk(KERN_ERR "skfp: region is not an MMIO resource\n");
  207. err = -EIO;
  208. goto err_out2;
  209. }
  210. mem = ioremap(pci_resource_start(pdev, 0), 0x4000);
  211. #else
  212. if (!(pci_resource_flags(pdev, 1) & IO_RESOURCE_IO)) {
  213. printk(KERN_ERR "skfp: region is not PIO resource\n");
  214. err = -EIO;
  215. goto err_out2;
  216. }
  217. mem = ioport_map(pci_resource_start(pdev, 1), FP_IO_LEN);
  218. #endif
  219. if (!mem) {
  220. printk(KERN_ERR "skfp: Unable to map register, "
  221. "FDDI adapter will be disabled.\n");
  222. err = -EIO;
  223. goto err_out2;
  224. }
  225. dev = alloc_fddidev(sizeof(struct s_smc));
  226. if (!dev) {
  227. printk(KERN_ERR "skfp: Unable to allocate fddi device, "
  228. "FDDI adapter will be disabled.\n");
  229. err = -ENOMEM;
  230. goto err_out3;
  231. }
  232. dev->irq = pdev->irq;
  233. dev->netdev_ops = &skfp_netdev_ops;
  234. SET_NETDEV_DEV(dev, &pdev->dev);
  235. /* Initialize board structure with bus-specific info */
  236. smc = netdev_priv(dev);
  237. smc->os.dev = dev;
  238. smc->os.bus_type = SK_BUS_TYPE_PCI;
  239. smc->os.pdev = *pdev;
  240. smc->os.QueueSkb = MAX_TX_QUEUE_LEN;
  241. smc->os.MaxFrameSize = MAX_FRAME_SIZE;
  242. smc->os.dev = dev;
  243. smc->hw.slot = -1;
  244. smc->hw.iop = mem;
  245. smc->os.ResetRequested = FALSE;
  246. skb_queue_head_init(&smc->os.SendSkbQueue);
  247. dev->base_addr = (unsigned long)mem;
  248. err = skfp_driver_init(dev);
  249. if (err)
  250. goto err_out4;
  251. err = register_netdev(dev);
  252. if (err)
  253. goto err_out5;
  254. ++num_boards;
  255. pci_set_drvdata(pdev, dev);
  256. if ((pdev->subsystem_device & 0xff00) == 0x5500 ||
  257. (pdev->subsystem_device & 0xff00) == 0x5800)
  258. printk("%s: SysKonnect FDDI PCI adapter"
  259. " found (SK-%04X)\n", dev->name,
  260. pdev->subsystem_device);
  261. else
  262. printk("%s: FDDI PCI adapter found\n", dev->name);
  263. return 0;
  264. err_out5:
  265. if (smc->os.SharedMemAddr)
  266. pci_free_consistent(pdev, smc->os.SharedMemSize,
  267. smc->os.SharedMemAddr,
  268. smc->os.SharedMemDMA);
  269. pci_free_consistent(pdev, MAX_FRAME_SIZE,
  270. smc->os.LocalRxBuffer, smc->os.LocalRxBufferDMA);
  271. err_out4:
  272. free_netdev(dev);
  273. err_out3:
  274. #ifdef MEM_MAPPED_IO
  275. iounmap(mem);
  276. #else
  277. ioport_unmap(mem);
  278. #endif
  279. err_out2:
  280. pci_release_regions(pdev);
  281. err_out1:
  282. pci_disable_device(pdev);
  283. return err;
  284. }
  285. /*
  286. * Called for each adapter board from pci_unregister_driver
  287. */
  288. static void __devexit skfp_remove_one(struct pci_dev *pdev)
  289. {
  290. struct net_device *p = pci_get_drvdata(pdev);
  291. struct s_smc *lp = netdev_priv(p);
  292. unregister_netdev(p);
  293. if (lp->os.SharedMemAddr) {
  294. pci_free_consistent(&lp->os.pdev,
  295. lp->os.SharedMemSize,
  296. lp->os.SharedMemAddr,
  297. lp->os.SharedMemDMA);
  298. lp->os.SharedMemAddr = NULL;
  299. }
  300. if (lp->os.LocalRxBuffer) {
  301. pci_free_consistent(&lp->os.pdev,
  302. MAX_FRAME_SIZE,
  303. lp->os.LocalRxBuffer,
  304. lp->os.LocalRxBufferDMA);
  305. lp->os.LocalRxBuffer = NULL;
  306. }
  307. #ifdef MEM_MAPPED_IO
  308. iounmap(lp->hw.iop);
  309. #else
  310. ioport_unmap(lp->hw.iop);
  311. #endif
  312. pci_release_regions(pdev);
  313. free_netdev(p);
  314. pci_disable_device(pdev);
  315. pci_set_drvdata(pdev, NULL);
  316. }
  317. /*
  318. * ====================
  319. * = skfp_driver_init =
  320. * ====================
  321. *
  322. * Overview:
  323. * Initializes remaining adapter board structure information
  324. * and makes sure adapter is in a safe state prior to skfp_open().
  325. *
  326. * Returns:
  327. * Condition code
  328. *
  329. * Arguments:
  330. * dev - pointer to device information
  331. *
  332. * Functional Description:
  333. * This function allocates additional resources such as the host memory
  334. * blocks needed by the adapter.
  335. * The adapter is also reset. The OS must call skfp_open() to open
  336. * the adapter and bring it on-line.
  337. *
  338. * Return Codes:
  339. * 0 - initialization succeeded
  340. * -1 - initialization failed
  341. */
  342. static int skfp_driver_init(struct net_device *dev)
  343. {
  344. struct s_smc *smc = netdev_priv(dev);
  345. skfddi_priv *bp = &smc->os;
  346. int err = -EIO;
  347. pr_debug(KERN_INFO "entering skfp_driver_init\n");
  348. // set the io address in private structures
  349. bp->base_addr = dev->base_addr;
  350. // Get the interrupt level from the PCI Configuration Table
  351. smc->hw.irq = dev->irq;
  352. spin_lock_init(&bp->DriverLock);
  353. // Allocate invalid frame
  354. bp->LocalRxBuffer = pci_alloc_consistent(&bp->pdev, MAX_FRAME_SIZE, &bp->LocalRxBufferDMA);
  355. if (!bp->LocalRxBuffer) {
  356. printk("could not allocate mem for ");
  357. printk("LocalRxBuffer: %d byte\n", MAX_FRAME_SIZE);
  358. goto fail;
  359. }
  360. // Determine the required size of the 'shared' memory area.
  361. bp->SharedMemSize = mac_drv_check_space();
  362. pr_debug(KERN_INFO "Memory for HWM: %ld\n", bp->SharedMemSize);
  363. if (bp->SharedMemSize > 0) {
  364. bp->SharedMemSize += 16; // for descriptor alignment
  365. bp->SharedMemAddr = pci_alloc_consistent(&bp->pdev,
  366. bp->SharedMemSize,
  367. &bp->SharedMemDMA);
  368. if (!bp->SharedMemSize) {
  369. printk("could not allocate mem for ");
  370. printk("hardware module: %ld byte\n",
  371. bp->SharedMemSize);
  372. goto fail;
  373. }
  374. bp->SharedMemHeap = 0; // Nothing used yet.
  375. } else {
  376. bp->SharedMemAddr = NULL;
  377. bp->SharedMemHeap = 0;
  378. } // SharedMemSize > 0
  379. memset(bp->SharedMemAddr, 0, bp->SharedMemSize);
  380. card_stop(smc); // Reset adapter.
  381. pr_debug(KERN_INFO "mac_drv_init()..\n");
  382. if (mac_drv_init(smc) != 0) {
  383. pr_debug(KERN_INFO "mac_drv_init() failed.\n");
  384. goto fail;
  385. }
  386. read_address(smc, NULL);
  387. pr_debug(KERN_INFO "HW-Addr: %02x %02x %02x %02x %02x %02x\n",
  388. smc->hw.fddi_canon_addr.a[0],
  389. smc->hw.fddi_canon_addr.a[1],
  390. smc->hw.fddi_canon_addr.a[2],
  391. smc->hw.fddi_canon_addr.a[3],
  392. smc->hw.fddi_canon_addr.a[4],
  393. smc->hw.fddi_canon_addr.a[5]);
  394. memcpy(dev->dev_addr, smc->hw.fddi_canon_addr.a, 6);
  395. smt_reset_defaults(smc, 0);
  396. return (0);
  397. fail:
  398. if (bp->SharedMemAddr) {
  399. pci_free_consistent(&bp->pdev,
  400. bp->SharedMemSize,
  401. bp->SharedMemAddr,
  402. bp->SharedMemDMA);
  403. bp->SharedMemAddr = NULL;
  404. }
  405. if (bp->LocalRxBuffer) {
  406. pci_free_consistent(&bp->pdev, MAX_FRAME_SIZE,
  407. bp->LocalRxBuffer, bp->LocalRxBufferDMA);
  408. bp->LocalRxBuffer = NULL;
  409. }
  410. return err;
  411. } // skfp_driver_init
  412. /*
  413. * =============
  414. * = skfp_open =
  415. * =============
  416. *
  417. * Overview:
  418. * Opens the adapter
  419. *
  420. * Returns:
  421. * Condition code
  422. *
  423. * Arguments:
  424. * dev - pointer to device information
  425. *
  426. * Functional Description:
  427. * This function brings the adapter to an operational state.
  428. *
  429. * Return Codes:
  430. * 0 - Adapter was successfully opened
  431. * -EAGAIN - Could not register IRQ
  432. */
  433. static int skfp_open(struct net_device *dev)
  434. {
  435. struct s_smc *smc = netdev_priv(dev);
  436. int err;
  437. pr_debug(KERN_INFO "entering skfp_open\n");
  438. /* Register IRQ - support shared interrupts by passing device ptr */
  439. err = request_irq(dev->irq, skfp_interrupt, IRQF_SHARED,
  440. dev->name, dev);
  441. if (err)
  442. return err;
  443. /*
  444. * Set current address to factory MAC address
  445. *
  446. * Note: We've already done this step in skfp_driver_init.
  447. * However, it's possible that a user has set a node
  448. * address override, then closed and reopened the
  449. * adapter. Unless we reset the device address field
  450. * now, we'll continue to use the existing modified
  451. * address.
  452. */
  453. read_address(smc, NULL);
  454. memcpy(dev->dev_addr, smc->hw.fddi_canon_addr.a, 6);
  455. init_smt(smc, NULL);
  456. smt_online(smc, 1);
  457. STI_FBI();
  458. /* Clear local multicast address tables */
  459. mac_clear_multicast(smc);
  460. /* Disable promiscuous filter settings */
  461. mac_drv_rx_mode(smc, RX_DISABLE_PROMISC);
  462. netif_start_queue(dev);
  463. return (0);
  464. } // skfp_open
  465. /*
  466. * ==============
  467. * = skfp_close =
  468. * ==============
  469. *
  470. * Overview:
  471. * Closes the device/module.
  472. *
  473. * Returns:
  474. * Condition code
  475. *
  476. * Arguments:
  477. * dev - pointer to device information
  478. *
  479. * Functional Description:
  480. * This routine closes the adapter and brings it to a safe state.
  481. * The interrupt service routine is deregistered with the OS.
  482. * The adapter can be opened again with another call to skfp_open().
  483. *
  484. * Return Codes:
  485. * Always return 0.
  486. *
  487. * Assumptions:
  488. * No further requests for this adapter are made after this routine is
  489. * called. skfp_open() can be called to reset and reinitialize the
  490. * adapter.
  491. */
  492. static int skfp_close(struct net_device *dev)
  493. {
  494. struct s_smc *smc = netdev_priv(dev);
  495. skfddi_priv *bp = &smc->os;
  496. CLI_FBI();
  497. smt_reset_defaults(smc, 1);
  498. card_stop(smc);
  499. mac_drv_clear_tx_queue(smc);
  500. mac_drv_clear_rx_queue(smc);
  501. netif_stop_queue(dev);
  502. /* Deregister (free) IRQ */
  503. free_irq(dev->irq, dev);
  504. skb_queue_purge(&bp->SendSkbQueue);
  505. bp->QueueSkb = MAX_TX_QUEUE_LEN;
  506. return (0);
  507. } // skfp_close
  508. /*
  509. * ==================
  510. * = skfp_interrupt =
  511. * ==================
  512. *
  513. * Overview:
  514. * Interrupt processing routine
  515. *
  516. * Returns:
  517. * None
  518. *
  519. * Arguments:
  520. * irq - interrupt vector
  521. * dev_id - pointer to device information
  522. *
  523. * Functional Description:
  524. * This routine calls the interrupt processing routine for this adapter. It
  525. * disables and reenables adapter interrupts, as appropriate. We can support
  526. * shared interrupts since the incoming dev_id pointer provides our device
  527. * structure context. All the real work is done in the hardware module.
  528. *
  529. * Return Codes:
  530. * None
  531. *
  532. * Assumptions:
  533. * The interrupt acknowledgement at the hardware level (eg. ACKing the PIC
  534. * on Intel-based systems) is done by the operating system outside this
  535. * routine.
  536. *
  537. * System interrupts are enabled through this call.
  538. *
  539. * Side Effects:
  540. * Interrupts are disabled, then reenabled at the adapter.
  541. */
  542. static irqreturn_t skfp_interrupt(int irq, void *dev_id)
  543. {
  544. struct net_device *dev = dev_id;
  545. struct s_smc *smc; /* private board structure pointer */
  546. skfddi_priv *bp;
  547. smc = netdev_priv(dev);
  548. bp = &smc->os;
  549. // IRQs enabled or disabled ?
  550. if (inpd(ADDR(B0_IMSK)) == 0) {
  551. // IRQs are disabled: must be shared interrupt
  552. return IRQ_NONE;
  553. }
  554. // Note: At this point, IRQs are enabled.
  555. if ((inpd(ISR_A) & smc->hw.is_imask) == 0) { // IRQ?
  556. // Adapter did not issue an IRQ: must be shared interrupt
  557. return IRQ_NONE;
  558. }
  559. CLI_FBI(); // Disable IRQs from our adapter.
  560. spin_lock(&bp->DriverLock);
  561. // Call interrupt handler in hardware module (HWM).
  562. fddi_isr(smc);
  563. if (smc->os.ResetRequested) {
  564. ResetAdapter(smc);
  565. smc->os.ResetRequested = FALSE;
  566. }
  567. spin_unlock(&bp->DriverLock);
  568. STI_FBI(); // Enable IRQs from our adapter.
  569. return IRQ_HANDLED;
  570. } // skfp_interrupt
  571. /*
  572. * ======================
  573. * = skfp_ctl_get_stats =
  574. * ======================
  575. *
  576. * Overview:
  577. * Get statistics for FDDI adapter
  578. *
  579. * Returns:
  580. * Pointer to FDDI statistics structure
  581. *
  582. * Arguments:
  583. * dev - pointer to device information
  584. *
  585. * Functional Description:
  586. * Gets current MIB objects from adapter, then
  587. * returns FDDI statistics structure as defined
  588. * in if_fddi.h.
  589. *
  590. * Note: Since the FDDI statistics structure is
  591. * still new and the device structure doesn't
  592. * have an FDDI-specific get statistics handler,
  593. * we'll return the FDDI statistics structure as
  594. * a pointer to an Ethernet statistics structure.
  595. * That way, at least the first part of the statistics
  596. * structure can be decoded properly.
  597. * We'll have to pay attention to this routine as the
  598. * device structure becomes more mature and LAN media
  599. * independent.
  600. *
  601. */
  602. static struct net_device_stats *skfp_ctl_get_stats(struct net_device *dev)
  603. {
  604. struct s_smc *bp = netdev_priv(dev);
  605. /* Fill the bp->stats structure with driver-maintained counters */
  606. bp->os.MacStat.port_bs_flag[0] = 0x1234;
  607. bp->os.MacStat.port_bs_flag[1] = 0x5678;
  608. // goos: need to fill out fddi statistic
  609. #if 0
  610. /* Get FDDI SMT MIB objects */
  611. /* Fill the bp->stats structure with the SMT MIB object values */
  612. memcpy(bp->stats.smt_station_id, &bp->cmd_rsp_virt->smt_mib_get.smt_station_id, sizeof(bp->cmd_rsp_virt->smt_mib_get.smt_station_id));
  613. bp->stats.smt_op_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_op_version_id;
  614. bp->stats.smt_hi_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_hi_version_id;
  615. bp->stats.smt_lo_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_lo_version_id;
  616. memcpy(bp->stats.smt_user_data, &bp->cmd_rsp_virt->smt_mib_get.smt_user_data, sizeof(bp->cmd_rsp_virt->smt_mib_get.smt_user_data));
  617. bp->stats.smt_mib_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_mib_version_id;
  618. bp->stats.smt_mac_cts = bp->cmd_rsp_virt->smt_mib_get.smt_mac_ct;
  619. bp->stats.smt_non_master_cts = bp->cmd_rsp_virt->smt_mib_get.smt_non_master_ct;
  620. bp->stats.smt_master_cts = bp->cmd_rsp_virt->smt_mib_get.smt_master_ct;
  621. bp->stats.smt_available_paths = bp->cmd_rsp_virt->smt_mib_get.smt_available_paths;
  622. bp->stats.smt_config_capabilities = bp->cmd_rsp_virt->smt_mib_get.smt_config_capabilities;
  623. bp->stats.smt_config_policy = bp->cmd_rsp_virt->smt_mib_get.smt_config_policy;
  624. bp->stats.smt_connection_policy = bp->cmd_rsp_virt->smt_mib_get.smt_connection_policy;
  625. bp->stats.smt_t_notify = bp->cmd_rsp_virt->smt_mib_get.smt_t_notify;
  626. bp->stats.smt_stat_rpt_policy = bp->cmd_rsp_virt->smt_mib_get.smt_stat_rpt_policy;
  627. bp->stats.smt_trace_max_expiration = bp->cmd_rsp_virt->smt_mib_get.smt_trace_max_expiration;
  628. bp->stats.smt_bypass_present = bp->cmd_rsp_virt->smt_mib_get.smt_bypass_present;
  629. bp->stats.smt_ecm_state = bp->cmd_rsp_virt->smt_mib_get.smt_ecm_state;
  630. bp->stats.smt_cf_state = bp->cmd_rsp_virt->smt_mib_get.smt_cf_state;
  631. bp->stats.smt_remote_disconnect_flag = bp->cmd_rsp_virt->smt_mib_get.smt_remote_disconnect_flag;
  632. bp->stats.smt_station_status = bp->cmd_rsp_virt->smt_mib_get.smt_station_status;
  633. bp->stats.smt_peer_wrap_flag = bp->cmd_rsp_virt->smt_mib_get.smt_peer_wrap_flag;
  634. bp->stats.smt_time_stamp = bp->cmd_rsp_virt->smt_mib_get.smt_msg_time_stamp.ls;
  635. bp->stats.smt_transition_time_stamp = bp->cmd_rsp_virt->smt_mib_get.smt_transition_time_stamp.ls;
  636. bp->stats.mac_frame_status_functions = bp->cmd_rsp_virt->smt_mib_get.mac_frame_status_functions;
  637. bp->stats.mac_t_max_capability = bp->cmd_rsp_virt->smt_mib_get.mac_t_max_capability;
  638. bp->stats.mac_tvx_capability = bp->cmd_rsp_virt->smt_mib_get.mac_tvx_capability;
  639. bp->stats.mac_available_paths = bp->cmd_rsp_virt->smt_mib_get.mac_available_paths;
  640. bp->stats.mac_current_path = bp->cmd_rsp_virt->smt_mib_get.mac_current_path;
  641. memcpy(bp->stats.mac_upstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_upstream_nbr, FDDI_K_ALEN);
  642. memcpy(bp->stats.mac_downstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_downstream_nbr, FDDI_K_ALEN);
  643. memcpy(bp->stats.mac_old_upstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_old_upstream_nbr, FDDI_K_ALEN);
  644. memcpy(bp->stats.mac_old_downstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_old_downstream_nbr, FDDI_K_ALEN);
  645. bp->stats.mac_dup_address_test = bp->cmd_rsp_virt->smt_mib_get.mac_dup_address_test;
  646. bp->stats.mac_requested_paths = bp->cmd_rsp_virt->smt_mib_get.mac_requested_paths;
  647. bp->stats.mac_downstream_port_type = bp->cmd_rsp_virt->smt_mib_get.mac_downstream_port_type;
  648. memcpy(bp->stats.mac_smt_address, &bp->cmd_rsp_virt->smt_mib_get.mac_smt_address, FDDI_K_ALEN);
  649. bp->stats.mac_t_req = bp->cmd_rsp_virt->smt_mib_get.mac_t_req;
  650. bp->stats.mac_t_neg = bp->cmd_rsp_virt->smt_mib_get.mac_t_neg;
  651. bp->stats.mac_t_max = bp->cmd_rsp_virt->smt_mib_get.mac_t_max;
  652. bp->stats.mac_tvx_value = bp->cmd_rsp_virt->smt_mib_get.mac_tvx_value;
  653. bp->stats.mac_frame_error_threshold = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_threshold;
  654. bp->stats.mac_frame_error_ratio = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_ratio;
  655. bp->stats.mac_rmt_state = bp->cmd_rsp_virt->smt_mib_get.mac_rmt_state;
  656. bp->stats.mac_da_flag = bp->cmd_rsp_virt->smt_mib_get.mac_da_flag;
  657. bp->stats.mac_una_da_flag = bp->cmd_rsp_virt->smt_mib_get.mac_unda_flag;
  658. bp->stats.mac_frame_error_flag = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_flag;
  659. bp->stats.mac_ma_unitdata_available = bp->cmd_rsp_virt->smt_mib_get.mac_ma_unitdata_available;
  660. bp->stats.mac_hardware_present = bp->cmd_rsp_virt->smt_mib_get.mac_hardware_present;
  661. bp->stats.mac_ma_unitdata_enable = bp->cmd_rsp_virt->smt_mib_get.mac_ma_unitdata_enable;
  662. bp->stats.path_tvx_lower_bound = bp->cmd_rsp_virt->smt_mib_get.path_tvx_lower_bound;
  663. bp->stats.path_t_max_lower_bound = bp->cmd_rsp_virt->smt_mib_get.path_t_max_lower_bound;
  664. bp->stats.path_max_t_req = bp->cmd_rsp_virt->smt_mib_get.path_max_t_req;
  665. memcpy(bp->stats.path_configuration, &bp->cmd_rsp_virt->smt_mib_get.path_configuration, sizeof(bp->cmd_rsp_virt->smt_mib_get.path_configuration));
  666. bp->stats.port_my_type[0] = bp->cmd_rsp_virt->smt_mib_get.port_my_type[0];
  667. bp->stats.port_my_type[1] = bp->cmd_rsp_virt->smt_mib_get.port_my_type[1];
  668. bp->stats.port_neighbor_type[0] = bp->cmd_rsp_virt->smt_mib_get.port_neighbor_type[0];
  669. bp->stats.port_neighbor_type[1] = bp->cmd_rsp_virt->smt_mib_get.port_neighbor_type[1];
  670. bp->stats.port_connection_policies[0] = bp->cmd_rsp_virt->smt_mib_get.port_connection_policies[0];
  671. bp->stats.port_connection_policies[1] = bp->cmd_rsp_virt->smt_mib_get.port_connection_policies[1];
  672. bp->stats.port_mac_indicated[0] = bp->cmd_rsp_virt->smt_mib_get.port_mac_indicated[0];
  673. bp->stats.port_mac_indicated[1] = bp->cmd_rsp_virt->smt_mib_get.port_mac_indicated[1];
  674. bp->stats.port_current_path[0] = bp->cmd_rsp_virt->smt_mib_get.port_current_path[0];
  675. bp->stats.port_current_path[1] = bp->cmd_rsp_virt->smt_mib_get.port_current_path[1];
  676. memcpy(&bp->stats.port_requested_paths[0 * 3], &bp->cmd_rsp_virt->smt_mib_get.port_requested_paths[0], 3);
  677. memcpy(&bp->stats.port_requested_paths[1 * 3], &bp->cmd_rsp_virt->smt_mib_get.port_requested_paths[1], 3);
  678. bp->stats.port_mac_placement[0] = bp->cmd_rsp_virt->smt_mib_get.port_mac_placement[0];
  679. bp->stats.port_mac_placement[1] = bp->cmd_rsp_virt->smt_mib_get.port_mac_placement[1];
  680. bp->stats.port_available_paths[0] = bp->cmd_rsp_virt->smt_mib_get.port_available_paths[0];
  681. bp->stats.port_available_paths[1] = bp->cmd_rsp_virt->smt_mib_get.port_available_paths[1];
  682. bp->stats.port_pmd_class[0] = bp->cmd_rsp_virt->smt_mib_get.port_pmd_class[0];
  683. bp->stats.port_pmd_class[1] = bp->cmd_rsp_virt->smt_mib_get.port_pmd_class[1];
  684. bp->stats.port_connection_capabilities[0] = bp->cmd_rsp_virt->smt_mib_get.port_connection_capabilities[0];
  685. bp->stats.port_connection_capabilities[1] = bp->cmd_rsp_virt->smt_mib_get.port_connection_capabilities[1];
  686. bp->stats.port_bs_flag[0] = bp->cmd_rsp_virt->smt_mib_get.port_bs_flag[0];
  687. bp->stats.port_bs_flag[1] = bp->cmd_rsp_virt->smt_mib_get.port_bs_flag[1];
  688. bp->stats.port_ler_estimate[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_estimate[0];
  689. bp->stats.port_ler_estimate[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_estimate[1];
  690. bp->stats.port_ler_cutoff[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_cutoff[0];
  691. bp->stats.port_ler_cutoff[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_cutoff[1];
  692. bp->stats.port_ler_alarm[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_alarm[0];
  693. bp->stats.port_ler_alarm[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_alarm[1];
  694. bp->stats.port_connect_state[0] = bp->cmd_rsp_virt->smt_mib_get.port_connect_state[0];
  695. bp->stats.port_connect_state[1] = bp->cmd_rsp_virt->smt_mib_get.port_connect_state[1];
  696. bp->stats.port_pcm_state[0] = bp->cmd_rsp_virt->smt_mib_get.port_pcm_state[0];
  697. bp->stats.port_pcm_state[1] = bp->cmd_rsp_virt->smt_mib_get.port_pcm_state[1];
  698. bp->stats.port_pc_withhold[0] = bp->cmd_rsp_virt->smt_mib_get.port_pc_withhold[0];
  699. bp->stats.port_pc_withhold[1] = bp->cmd_rsp_virt->smt_mib_get.port_pc_withhold[1];
  700. bp->stats.port_ler_flag[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_flag[0];
  701. bp->stats.port_ler_flag[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_flag[1];
  702. bp->stats.port_hardware_present[0] = bp->cmd_rsp_virt->smt_mib_get.port_hardware_present[0];
  703. bp->stats.port_hardware_present[1] = bp->cmd_rsp_virt->smt_mib_get.port_hardware_present[1];
  704. /* Fill the bp->stats structure with the FDDI counter values */
  705. bp->stats.mac_frame_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.frame_cnt.ls;
  706. bp->stats.mac_copied_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.copied_cnt.ls;
  707. bp->stats.mac_transmit_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.transmit_cnt.ls;
  708. bp->stats.mac_error_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.error_cnt.ls;
  709. bp->stats.mac_lost_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.lost_cnt.ls;
  710. bp->stats.port_lct_fail_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.lct_rejects[0].ls;
  711. bp->stats.port_lct_fail_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.lct_rejects[1].ls;
  712. bp->stats.port_lem_reject_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.lem_rejects[0].ls;
  713. bp->stats.port_lem_reject_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.lem_rejects[1].ls;
  714. bp->stats.port_lem_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.link_errors[0].ls;
  715. bp->stats.port_lem_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.link_errors[1].ls;
  716. #endif
  717. return ((struct net_device_stats *) &bp->os.MacStat);
  718. } // ctl_get_stat
  719. /*
  720. * ==============================
  721. * = skfp_ctl_set_multicast_list =
  722. * ==============================
  723. *
  724. * Overview:
  725. * Enable/Disable LLC frame promiscuous mode reception
  726. * on the adapter and/or update multicast address table.
  727. *
  728. * Returns:
  729. * None
  730. *
  731. * Arguments:
  732. * dev - pointer to device information
  733. *
  734. * Functional Description:
  735. * This function acquires the driver lock and only calls
  736. * skfp_ctl_set_multicast_list_wo_lock then.
  737. * This routine follows a fairly simple algorithm for setting the
  738. * adapter filters and CAM:
  739. *
  740. * if IFF_PROMISC flag is set
  741. * enable promiscuous mode
  742. * else
  743. * disable promiscuous mode
  744. * if number of multicast addresses <= max. multicast number
  745. * add mc addresses to adapter table
  746. * else
  747. * enable promiscuous mode
  748. * update adapter filters
  749. *
  750. * Assumptions:
  751. * Multicast addresses are presented in canonical (LSB) format.
  752. *
  753. * Side Effects:
  754. * On-board adapter filters are updated.
  755. */
  756. static void skfp_ctl_set_multicast_list(struct net_device *dev)
  757. {
  758. struct s_smc *smc = netdev_priv(dev);
  759. skfddi_priv *bp = &smc->os;
  760. unsigned long Flags;
  761. spin_lock_irqsave(&bp->DriverLock, Flags);
  762. skfp_ctl_set_multicast_list_wo_lock(dev);
  763. spin_unlock_irqrestore(&bp->DriverLock, Flags);
  764. return;
  765. } // skfp_ctl_set_multicast_list
  766. static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev)
  767. {
  768. struct s_smc *smc = netdev_priv(dev);
  769. struct dev_mc_list *dmi; /* ptr to multicast addr entry */
  770. int i;
  771. /* Enable promiscuous mode, if necessary */
  772. if (dev->flags & IFF_PROMISC) {
  773. mac_drv_rx_mode(smc, RX_ENABLE_PROMISC);
  774. pr_debug(KERN_INFO "PROMISCUOUS MODE ENABLED\n");
  775. }
  776. /* Else, update multicast address table */
  777. else {
  778. mac_drv_rx_mode(smc, RX_DISABLE_PROMISC);
  779. pr_debug(KERN_INFO "PROMISCUOUS MODE DISABLED\n");
  780. // Reset all MC addresses
  781. mac_clear_multicast(smc);
  782. mac_drv_rx_mode(smc, RX_DISABLE_ALLMULTI);
  783. if (dev->flags & IFF_ALLMULTI) {
  784. mac_drv_rx_mode(smc, RX_ENABLE_ALLMULTI);
  785. pr_debug(KERN_INFO "ENABLE ALL MC ADDRESSES\n");
  786. } else if (dev->mc_count > 0) {
  787. if (dev->mc_count <= FPMAX_MULTICAST) {
  788. /* use exact filtering */
  789. // point to first multicast addr
  790. dmi = dev->mc_list;
  791. for (i = 0; i < dev->mc_count; i++) {
  792. mac_add_multicast(smc,
  793. (struct fddi_addr *)dmi->dmi_addr,
  794. 1);
  795. pr_debug(KERN_INFO "ENABLE MC ADDRESS:");
  796. pr_debug(" %02x %02x %02x ",
  797. dmi->dmi_addr[0],
  798. dmi->dmi_addr[1],
  799. dmi->dmi_addr[2]);
  800. pr_debug("%02x %02x %02x\n",
  801. dmi->dmi_addr[3],
  802. dmi->dmi_addr[4],
  803. dmi->dmi_addr[5]);
  804. dmi = dmi->next;
  805. } // for
  806. } else { // more MC addresses than HW supports
  807. mac_drv_rx_mode(smc, RX_ENABLE_ALLMULTI);
  808. pr_debug(KERN_INFO "ENABLE ALL MC ADDRESSES\n");
  809. }
  810. } else { // no MC addresses
  811. pr_debug(KERN_INFO "DISABLE ALL MC ADDRESSES\n");
  812. }
  813. /* Update adapter filters */
  814. mac_update_multicast(smc);
  815. }
  816. return;
  817. } // skfp_ctl_set_multicast_list_wo_lock
  818. /*
  819. * ===========================
  820. * = skfp_ctl_set_mac_address =
  821. * ===========================
  822. *
  823. * Overview:
  824. * set new mac address on adapter and update dev_addr field in device table.
  825. *
  826. * Returns:
  827. * None
  828. *
  829. * Arguments:
  830. * dev - pointer to device information
  831. * addr - pointer to sockaddr structure containing unicast address to set
  832. *
  833. * Assumptions:
  834. * The address pointed to by addr->sa_data is a valid unicast
  835. * address and is presented in canonical (LSB) format.
  836. */
  837. static int skfp_ctl_set_mac_address(struct net_device *dev, void *addr)
  838. {
  839. struct s_smc *smc = netdev_priv(dev);
  840. struct sockaddr *p_sockaddr = (struct sockaddr *) addr;
  841. skfddi_priv *bp = &smc->os;
  842. unsigned long Flags;
  843. memcpy(dev->dev_addr, p_sockaddr->sa_data, FDDI_K_ALEN);
  844. spin_lock_irqsave(&bp->DriverLock, Flags);
  845. ResetAdapter(smc);
  846. spin_unlock_irqrestore(&bp->DriverLock, Flags);
  847. return (0); /* always return zero */
  848. } // skfp_ctl_set_mac_address
  849. /*
  850. * ==============
  851. * = skfp_ioctl =
  852. * ==============
  853. *
  854. * Overview:
  855. *
  856. * Perform IOCTL call functions here. Some are privileged operations and the
  857. * effective uid is checked in those cases.
  858. *
  859. * Returns:
  860. * status value
  861. * 0 - success
  862. * other - failure
  863. *
  864. * Arguments:
  865. * dev - pointer to device information
  866. * rq - pointer to ioctl request structure
  867. * cmd - ?
  868. *
  869. */
  870. static int skfp_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  871. {
  872. struct s_smc *smc = netdev_priv(dev);
  873. skfddi_priv *lp = &smc->os;
  874. struct s_skfp_ioctl ioc;
  875. int status = 0;
  876. if (copy_from_user(&ioc, rq->ifr_data, sizeof(struct s_skfp_ioctl)))
  877. return -EFAULT;
  878. switch (ioc.cmd) {
  879. case SKFP_GET_STATS: /* Get the driver statistics */
  880. ioc.len = sizeof(lp->MacStat);
  881. status = copy_to_user(ioc.data, skfp_ctl_get_stats(dev), ioc.len)
  882. ? -EFAULT : 0;
  883. break;
  884. case SKFP_CLR_STATS: /* Zero out the driver statistics */
  885. if (!capable(CAP_NET_ADMIN)) {
  886. status = -EPERM;
  887. } else {
  888. memset(&lp->MacStat, 0, sizeof(lp->MacStat));
  889. }
  890. break;
  891. default:
  892. printk("ioctl for %s: unknow cmd: %04x\n", dev->name, ioc.cmd);
  893. status = -EOPNOTSUPP;
  894. } // switch
  895. return status;
  896. } // skfp_ioctl
  897. /*
  898. * =====================
  899. * = skfp_send_pkt =
  900. * =====================
  901. *
  902. * Overview:
  903. * Queues a packet for transmission and try to transmit it.
  904. *
  905. * Returns:
  906. * Condition code
  907. *
  908. * Arguments:
  909. * skb - pointer to sk_buff to queue for transmission
  910. * dev - pointer to device information
  911. *
  912. * Functional Description:
  913. * Here we assume that an incoming skb transmit request
  914. * is contained in a single physically contiguous buffer
  915. * in which the virtual address of the start of packet
  916. * (skb->data) can be converted to a physical address
  917. * by using pci_map_single().
  918. *
  919. * We have an internal queue for packets we can not send
  920. * immediately. Packets in this queue can be given to the
  921. * adapter if transmit buffers are freed.
  922. *
  923. * We can't free the skb until after it's been DMA'd
  924. * out by the adapter, so we'll keep it in the driver and
  925. * return it in mac_drv_tx_complete.
  926. *
  927. * Return Codes:
  928. * 0 - driver has queued and/or sent packet
  929. * 1 - caller should requeue the sk_buff for later transmission
  930. *
  931. * Assumptions:
  932. * The entire packet is stored in one physically
  933. * contiguous buffer which is not cached and whose
  934. * 32-bit physical address can be determined.
  935. *
  936. * It's vital that this routine is NOT reentered for the
  937. * same board and that the OS is not in another section of
  938. * code (eg. skfp_interrupt) for the same board on a
  939. * different thread.
  940. *
  941. * Side Effects:
  942. * None
  943. */
  944. static netdev_tx_t skfp_send_pkt(struct sk_buff *skb,
  945. struct net_device *dev)
  946. {
  947. struct s_smc *smc = netdev_priv(dev);
  948. skfddi_priv *bp = &smc->os;
  949. pr_debug(KERN_INFO "skfp_send_pkt\n");
  950. /*
  951. * Verify that incoming transmit request is OK
  952. *
  953. * Note: The packet size check is consistent with other
  954. * Linux device drivers, although the correct packet
  955. * size should be verified before calling the
  956. * transmit routine.
  957. */
  958. if (!(skb->len >= FDDI_K_LLC_ZLEN && skb->len <= FDDI_K_LLC_LEN)) {
  959. bp->MacStat.gen.tx_errors++; /* bump error counter */
  960. // dequeue packets from xmt queue and send them
  961. netif_start_queue(dev);
  962. dev_kfree_skb(skb);
  963. return NETDEV_TX_OK; /* return "success" */
  964. }
  965. if (bp->QueueSkb == 0) { // return with tbusy set: queue full
  966. netif_stop_queue(dev);
  967. return NETDEV_TX_BUSY;
  968. }
  969. bp->QueueSkb--;
  970. skb_queue_tail(&bp->SendSkbQueue, skb);
  971. send_queued_packets(netdev_priv(dev));
  972. if (bp->QueueSkb == 0) {
  973. netif_stop_queue(dev);
  974. }
  975. dev->trans_start = jiffies;
  976. return NETDEV_TX_OK;
  977. } // skfp_send_pkt
  978. /*
  979. * =======================
  980. * = send_queued_packets =
  981. * =======================
  982. *
  983. * Overview:
  984. * Send packets from the driver queue as long as there are some and
  985. * transmit resources are available.
  986. *
  987. * Returns:
  988. * None
  989. *
  990. * Arguments:
  991. * smc - pointer to smc (adapter) structure
  992. *
  993. * Functional Description:
  994. * Take a packet from queue if there is any. If not, then we are done.
  995. * Check if there are resources to send the packet. If not, requeue it
  996. * and exit.
  997. * Set packet descriptor flags and give packet to adapter.
  998. * Check if any send resources can be freed (we do not use the
  999. * transmit complete interrupt).
  1000. */
  1001. static void send_queued_packets(struct s_smc *smc)
  1002. {
  1003. skfddi_priv *bp = &smc->os;
  1004. struct sk_buff *skb;
  1005. unsigned char fc;
  1006. int queue;
  1007. struct s_smt_fp_txd *txd; // Current TxD.
  1008. dma_addr_t dma_address;
  1009. unsigned long Flags;
  1010. int frame_status; // HWM tx frame status.
  1011. pr_debug(KERN_INFO "send queued packets\n");
  1012. for (;;) {
  1013. // send first buffer from queue
  1014. skb = skb_dequeue(&bp->SendSkbQueue);
  1015. if (!skb) {
  1016. pr_debug(KERN_INFO "queue empty\n");
  1017. return;
  1018. } // queue empty !
  1019. spin_lock_irqsave(&bp->DriverLock, Flags);
  1020. fc = skb->data[0];
  1021. queue = (fc & FC_SYNC_BIT) ? QUEUE_S : QUEUE_A0;
  1022. #ifdef ESS
  1023. // Check if the frame may/must be sent as a synchronous frame.
  1024. if ((fc & ~(FC_SYNC_BIT | FC_LLC_PRIOR)) == FC_ASYNC_LLC) {
  1025. // It's an LLC frame.
  1026. if (!smc->ess.sync_bw_available)
  1027. fc &= ~FC_SYNC_BIT; // No bandwidth available.
  1028. else { // Bandwidth is available.
  1029. if (smc->mib.fddiESSSynchTxMode) {
  1030. // Send as sync. frame.
  1031. fc |= FC_SYNC_BIT;
  1032. }
  1033. }
  1034. }
  1035. #endif // ESS
  1036. frame_status = hwm_tx_init(smc, fc, 1, skb->len, queue);
  1037. if ((frame_status & (LOC_TX | LAN_TX)) == 0) {
  1038. // Unable to send the frame.
  1039. if ((frame_status & RING_DOWN) != 0) {
  1040. // Ring is down.
  1041. pr_debug("Tx attempt while ring down.\n");
  1042. } else if ((frame_status & OUT_OF_TXD) != 0) {
  1043. pr_debug("%s: out of TXDs.\n", bp->dev->name);
  1044. } else {
  1045. pr_debug("%s: out of transmit resources",
  1046. bp->dev->name);
  1047. }
  1048. // Note: We will retry the operation as soon as
  1049. // transmit resources become available.
  1050. skb_queue_head(&bp->SendSkbQueue, skb);
  1051. spin_unlock_irqrestore(&bp->DriverLock, Flags);
  1052. return; // Packet has been queued.
  1053. } // if (unable to send frame)
  1054. bp->QueueSkb++; // one packet less in local queue
  1055. // source address in packet ?
  1056. CheckSourceAddress(skb->data, smc->hw.fddi_canon_addr.a);
  1057. txd = (struct s_smt_fp_txd *) HWM_GET_CURR_TXD(smc, queue);
  1058. dma_address = pci_map_single(&bp->pdev, skb->data,
  1059. skb->len, PCI_DMA_TODEVICE);
  1060. if (frame_status & LAN_TX) {
  1061. txd->txd_os.skb = skb; // save skb
  1062. txd->txd_os.dma_addr = dma_address; // save dma mapping
  1063. }
  1064. hwm_tx_frag(smc, skb->data, dma_address, skb->len,
  1065. frame_status | FIRST_FRAG | LAST_FRAG | EN_IRQ_EOF);
  1066. if (!(frame_status & LAN_TX)) { // local only frame
  1067. pci_unmap_single(&bp->pdev, dma_address,
  1068. skb->len, PCI_DMA_TODEVICE);
  1069. dev_kfree_skb_irq(skb);
  1070. }
  1071. spin_unlock_irqrestore(&bp->DriverLock, Flags);
  1072. } // for
  1073. return; // never reached
  1074. } // send_queued_packets
  1075. /************************
  1076. *
  1077. * CheckSourceAddress
  1078. *
  1079. * Verify if the source address is set. Insert it if necessary.
  1080. *
  1081. ************************/
  1082. static void CheckSourceAddress(unsigned char *frame, unsigned char *hw_addr)
  1083. {
  1084. unsigned char SRBit;
  1085. if ((((unsigned long) frame[1 + 6]) & ~0x01) != 0) // source routing bit
  1086. return;
  1087. if ((unsigned short) frame[1 + 10] != 0)
  1088. return;
  1089. SRBit = frame[1 + 6] & 0x01;
  1090. memcpy(&frame[1 + 6], hw_addr, 6);
  1091. frame[8] |= SRBit;
  1092. } // CheckSourceAddress
  1093. /************************
  1094. *
  1095. * ResetAdapter
  1096. *
  1097. * Reset the adapter and bring it back to operational mode.
  1098. * Args
  1099. * smc - A pointer to the SMT context struct.
  1100. * Out
  1101. * Nothing.
  1102. *
  1103. ************************/
  1104. static void ResetAdapter(struct s_smc *smc)
  1105. {
  1106. pr_debug(KERN_INFO "[fddi: ResetAdapter]\n");
  1107. // Stop the adapter.
  1108. card_stop(smc); // Stop all activity.
  1109. // Clear the transmit and receive descriptor queues.
  1110. mac_drv_clear_tx_queue(smc);
  1111. mac_drv_clear_rx_queue(smc);
  1112. // Restart the adapter.
  1113. smt_reset_defaults(smc, 1); // Initialize the SMT module.
  1114. init_smt(smc, (smc->os.dev)->dev_addr); // Initialize the hardware.
  1115. smt_online(smc, 1); // Insert into the ring again.
  1116. STI_FBI();
  1117. // Restore original receive mode (multicasts, promiscuous, etc.).
  1118. skfp_ctl_set_multicast_list_wo_lock(smc->os.dev);
  1119. } // ResetAdapter
  1120. //--------------- functions called by hardware module ----------------
  1121. /************************
  1122. *
  1123. * llc_restart_tx
  1124. *
  1125. * The hardware driver calls this routine when the transmit complete
  1126. * interrupt bits (end of frame) for the synchronous or asynchronous
  1127. * queue is set.
  1128. *
  1129. * NOTE The hardware driver calls this function also if no packets are queued.
  1130. * The routine must be able to handle this case.
  1131. * Args
  1132. * smc - A pointer to the SMT context struct.
  1133. * Out
  1134. * Nothing.
  1135. *
  1136. ************************/
  1137. void llc_restart_tx(struct s_smc *smc)
  1138. {
  1139. skfddi_priv *bp = &smc->os;
  1140. pr_debug(KERN_INFO "[llc_restart_tx]\n");
  1141. // Try to send queued packets
  1142. spin_unlock(&bp->DriverLock);
  1143. send_queued_packets(smc);
  1144. spin_lock(&bp->DriverLock);
  1145. netif_start_queue(bp->dev);// system may send again if it was blocked
  1146. } // llc_restart_tx
  1147. /************************
  1148. *
  1149. * mac_drv_get_space
  1150. *
  1151. * The hardware module calls this function to allocate the memory
  1152. * for the SMT MBufs if the define MB_OUTSIDE_SMC is specified.
  1153. * Args
  1154. * smc - A pointer to the SMT context struct.
  1155. *
  1156. * size - Size of memory in bytes to allocate.
  1157. * Out
  1158. * != 0 A pointer to the virtual address of the allocated memory.
  1159. * == 0 Allocation error.
  1160. *
  1161. ************************/
  1162. void *mac_drv_get_space(struct s_smc *smc, unsigned int size)
  1163. {
  1164. void *virt;
  1165. pr_debug(KERN_INFO "mac_drv_get_space (%d bytes), ", size);
  1166. virt = (void *) (smc->os.SharedMemAddr + smc->os.SharedMemHeap);
  1167. if ((smc->os.SharedMemHeap + size) > smc->os.SharedMemSize) {
  1168. printk("Unexpected SMT memory size requested: %d\n", size);
  1169. return (NULL);
  1170. }
  1171. smc->os.SharedMemHeap += size; // Move heap pointer.
  1172. pr_debug(KERN_INFO "mac_drv_get_space end\n");
  1173. pr_debug(KERN_INFO "virt addr: %lx\n", (ulong) virt);
  1174. pr_debug(KERN_INFO "bus addr: %lx\n", (ulong)
  1175. (smc->os.SharedMemDMA +
  1176. ((char *) virt - (char *)smc->os.SharedMemAddr)));
  1177. return (virt);
  1178. } // mac_drv_get_space
  1179. /************************
  1180. *
  1181. * mac_drv_get_desc_mem
  1182. *
  1183. * This function is called by the hardware dependent module.
  1184. * It allocates the memory for the RxD and TxD descriptors.
  1185. *
  1186. * This memory must be non-cached, non-movable and non-swappable.
  1187. * This memory should start at a physical page boundary.
  1188. * Args
  1189. * smc - A pointer to the SMT context struct.
  1190. *
  1191. * size - Size of memory in bytes to allocate.
  1192. * Out
  1193. * != 0 A pointer to the virtual address of the allocated memory.
  1194. * == 0 Allocation error.
  1195. *
  1196. ************************/
  1197. void *mac_drv_get_desc_mem(struct s_smc *smc, unsigned int size)
  1198. {
  1199. char *virt;
  1200. pr_debug(KERN_INFO "mac_drv_get_desc_mem\n");
  1201. // Descriptor memory must be aligned on 16-byte boundary.
  1202. virt = mac_drv_get_space(smc, size);
  1203. size = (u_int) (16 - (((unsigned long) virt) & 15UL));
  1204. size = size % 16;
  1205. pr_debug("Allocate %u bytes alignment gap ", size);
  1206. pr_debug("for descriptor memory.\n");
  1207. if (!mac_drv_get_space(smc, size)) {
  1208. printk("fddi: Unable to align descriptor memory.\n");
  1209. return (NULL);
  1210. }
  1211. return (virt + size);
  1212. } // mac_drv_get_desc_mem
  1213. /************************
  1214. *
  1215. * mac_drv_virt2phys
  1216. *
  1217. * Get the physical address of a given virtual address.
  1218. * Args
  1219. * smc - A pointer to the SMT context struct.
  1220. *
  1221. * virt - A (virtual) pointer into our 'shared' memory area.
  1222. * Out
  1223. * Physical address of the given virtual address.
  1224. *
  1225. ************************/
  1226. unsigned long mac_drv_virt2phys(struct s_smc *smc, void *virt)
  1227. {
  1228. return (smc->os.SharedMemDMA +
  1229. ((char *) virt - (char *)smc->os.SharedMemAddr));
  1230. } // mac_drv_virt2phys
  1231. /************************
  1232. *
  1233. * dma_master
  1234. *
  1235. * The HWM calls this function, when the driver leads through a DMA
  1236. * transfer. If the OS-specific module must prepare the system hardware
  1237. * for the DMA transfer, it should do it in this function.
  1238. *
  1239. * The hardware module calls this dma_master if it wants to send an SMT
  1240. * frame. This means that the virt address passed in here is part of
  1241. * the 'shared' memory area.
  1242. * Args
  1243. * smc - A pointer to the SMT context struct.
  1244. *
  1245. * virt - The virtual address of the data.
  1246. *
  1247. * len - The length in bytes of the data.
  1248. *
  1249. * flag - Indicates the transmit direction and the buffer type:
  1250. * DMA_RD (0x01) system RAM ==> adapter buffer memory
  1251. * DMA_WR (0x02) adapter buffer memory ==> system RAM
  1252. * SMT_BUF (0x80) SMT buffer
  1253. *
  1254. * >> NOTE: SMT_BUF and DMA_RD are always set for PCI. <<
  1255. * Out
  1256. * Returns the pyhsical address for the DMA transfer.
  1257. *
  1258. ************************/
  1259. u_long dma_master(struct s_smc * smc, void *virt, int len, int flag)
  1260. {
  1261. return (smc->os.SharedMemDMA +
  1262. ((char *) virt - (char *)smc->os.SharedMemAddr));
  1263. } // dma_master
  1264. /************************
  1265. *
  1266. * dma_complete
  1267. *
  1268. * The hardware module calls this routine when it has completed a DMA
  1269. * transfer. If the operating system dependent module has set up the DMA
  1270. * channel via dma_master() (e.g. Windows NT or AIX) it should clean up
  1271. * the DMA channel.
  1272. * Args
  1273. * smc - A pointer to the SMT context struct.
  1274. *
  1275. * descr - A pointer to a TxD or RxD, respectively.
  1276. *
  1277. * flag - Indicates the DMA transfer direction / SMT buffer:
  1278. * DMA_RD (0x01) system RAM ==> adapter buffer memory
  1279. * DMA_WR (0x02) adapter buffer memory ==> system RAM
  1280. * SMT_BUF (0x80) SMT buffer (managed by HWM)
  1281. * Out
  1282. * Nothing.
  1283. *
  1284. ************************/
  1285. void dma_complete(struct s_smc *smc, volatile union s_fp_descr *descr, int flag)
  1286. {
  1287. /* For TX buffers, there are two cases. If it is an SMT transmit
  1288. * buffer, there is nothing to do since we use consistent memory
  1289. * for the 'shared' memory area. The other case is for normal
  1290. * transmit packets given to us by the networking stack, and in
  1291. * that case we cleanup the PCI DMA mapping in mac_drv_tx_complete
  1292. * below.
  1293. *
  1294. * For RX buffers, we have to unmap dynamic PCI DMA mappings here
  1295. * because the hardware module is about to potentially look at
  1296. * the contents of the buffer. If we did not call the PCI DMA
  1297. * unmap first, the hardware module could read inconsistent data.
  1298. */
  1299. if (flag & DMA_WR) {
  1300. skfddi_priv *bp = &smc->os;
  1301. volatile struct s_smt_fp_rxd *r = &descr->r;
  1302. /* If SKB is NULL, we used the local buffer. */
  1303. if (r->rxd_os.skb && r->rxd_os.dma_addr) {
  1304. int MaxFrameSize = bp->MaxFrameSize;
  1305. pci_unmap_single(&bp->pdev, r->rxd_os.dma_addr,
  1306. MaxFrameSize, PCI_DMA_FROMDEVICE);
  1307. r->rxd_os.dma_addr = 0;
  1308. }
  1309. }
  1310. } // dma_complete
  1311. /************************
  1312. *
  1313. * mac_drv_tx_complete
  1314. *
  1315. * Transmit of a packet is complete. Release the tx staging buffer.
  1316. *
  1317. * Args
  1318. * smc - A pointer to the SMT context struct.
  1319. *
  1320. * txd - A pointer to the last TxD which is used by the frame.
  1321. * Out
  1322. * Returns nothing.
  1323. *
  1324. ************************/
  1325. void mac_drv_tx_complete(struct s_smc *smc, volatile struct s_smt_fp_txd *txd)
  1326. {
  1327. struct sk_buff *skb;
  1328. pr_debug(KERN_INFO "entering mac_drv_tx_complete\n");
  1329. // Check if this TxD points to a skb
  1330. if (!(skb = txd->txd_os.skb)) {
  1331. pr_debug("TXD with no skb assigned.\n");
  1332. return;
  1333. }
  1334. txd->txd_os.skb = NULL;
  1335. // release the DMA mapping
  1336. pci_unmap_single(&smc->os.pdev, txd->txd_os.dma_addr,
  1337. skb->len, PCI_DMA_TODEVICE);
  1338. txd->txd_os.dma_addr = 0;
  1339. smc->os.MacStat.gen.tx_packets++; // Count transmitted packets.
  1340. smc->os.MacStat.gen.tx_bytes+=skb->len; // Count bytes
  1341. // free the skb
  1342. dev_kfree_skb_irq(skb);
  1343. pr_debug(KERN_INFO "leaving mac_drv_tx_complete\n");
  1344. } // mac_drv_tx_complete
  1345. /************************
  1346. *
  1347. * dump packets to logfile
  1348. *
  1349. ************************/
  1350. #ifdef DUMPPACKETS
  1351. void dump_data(unsigned char *Data, int length)
  1352. {
  1353. int i, j;
  1354. unsigned char s[255], sh[10];
  1355. if (length > 64) {
  1356. length = 64;
  1357. }
  1358. printk(KERN_INFO "---Packet start---\n");
  1359. for (i = 0, j = 0; i < length / 8; i++, j += 8)
  1360. printk(KERN_INFO "%02x %02x %02x %02x %02x %02x %02x %02x\n",
  1361. Data[j + 0], Data[j + 1], Data[j + 2], Data[j + 3],
  1362. Data[j + 4], Data[j + 5], Data[j + 6], Data[j + 7]);
  1363. strcpy(s, "");
  1364. for (i = 0; i < length % 8; i++) {
  1365. sprintf(sh, "%02x ", Data[j + i]);
  1366. strcat(s, sh);
  1367. }
  1368. printk(KERN_INFO "%s\n", s);
  1369. printk(KERN_INFO "------------------\n");
  1370. } // dump_data
  1371. #else
  1372. #define dump_data(data,len)
  1373. #endif // DUMPPACKETS
  1374. /************************
  1375. *
  1376. * mac_drv_rx_complete
  1377. *
  1378. * The hardware module calls this function if an LLC frame is received
  1379. * in a receive buffer. Also the SMT, NSA, and directed beacon frames
  1380. * from the network will be passed to the LLC layer by this function
  1381. * if passing is enabled.
  1382. *
  1383. * mac_drv_rx_complete forwards the frame to the LLC layer if it should
  1384. * be received. It also fills the RxD ring with new receive buffers if
  1385. * some can be queued.
  1386. * Args
  1387. * smc - A pointer to the SMT context struct.
  1388. *
  1389. * rxd - A pointer to the first RxD which is used by the receive frame.
  1390. *
  1391. * frag_count - Count of RxDs used by the received frame.
  1392. *
  1393. * len - Frame length.
  1394. * Out
  1395. * Nothing.
  1396. *
  1397. ************************/
  1398. void mac_drv_rx_complete(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
  1399. int frag_count, int len)
  1400. {
  1401. skfddi_priv *bp = &smc->os;
  1402. struct sk_buff *skb;
  1403. unsigned char *virt, *cp;
  1404. unsigned short ri;
  1405. u_int RifLength;
  1406. pr_debug(KERN_INFO "entering mac_drv_rx_complete (len=%d)\n", len);
  1407. if (frag_count != 1) { // This is not allowed to happen.
  1408. printk("fddi: Multi-fragment receive!\n");
  1409. goto RequeueRxd; // Re-use the given RXD(s).
  1410. }
  1411. skb = rxd->rxd_os.skb;
  1412. if (!skb) {
  1413. pr_debug(KERN_INFO "No skb in rxd\n");
  1414. smc->os.MacStat.gen.rx_errors++;
  1415. goto RequeueRxd;
  1416. }
  1417. virt = skb->data;
  1418. // The DMA mapping was released in dma_complete above.
  1419. dump_data(skb->data, len);
  1420. /*
  1421. * FDDI Frame format:
  1422. * +-------+-------+-------+------------+--------+------------+
  1423. * | FC[1] | DA[6] | SA[6] | RIF[0..18] | LLC[3] | Data[0..n] |
  1424. * +-------+-------+-------+------------+--------+------------+
  1425. *
  1426. * FC = Frame Control
  1427. * DA = Destination Address
  1428. * SA = Source Address
  1429. * RIF = Routing Information Field
  1430. * LLC = Logical Link Control
  1431. */
  1432. // Remove Routing Information Field (RIF), if present.
  1433. if ((virt[1 + 6] & FDDI_RII) == 0)
  1434. RifLength = 0;
  1435. else {
  1436. int n;
  1437. // goos: RIF removal has still to be tested
  1438. pr_debug(KERN_INFO "RIF found\n");
  1439. // Get RIF length from Routing Control (RC) field.
  1440. cp = virt + FDDI_MAC_HDR_LEN; // Point behind MAC header.
  1441. ri = ntohs(*((__be16 *) cp));
  1442. RifLength = ri & FDDI_RCF_LEN_MASK;
  1443. if (len < (int) (FDDI_MAC_HDR_LEN + RifLength)) {
  1444. printk("fddi: Invalid RIF.\n");
  1445. goto RequeueRxd; // Discard the frame.
  1446. }
  1447. virt[1 + 6] &= ~FDDI_RII; // Clear RII bit.
  1448. // regions overlap
  1449. virt = cp + RifLength;
  1450. for (n = FDDI_MAC_HDR_LEN; n; n--)
  1451. *--virt = *--cp;
  1452. // adjust sbd->data pointer
  1453. skb_pull(skb, RifLength);
  1454. len -= RifLength;
  1455. RifLength = 0;
  1456. }
  1457. // Count statistics.
  1458. smc->os.MacStat.gen.rx_packets++; // Count indicated receive
  1459. // packets.
  1460. smc->os.MacStat.gen.rx_bytes+=len; // Count bytes.
  1461. // virt points to header again
  1462. if (virt[1] & 0x01) { // Check group (multicast) bit.
  1463. smc->os.MacStat.gen.multicast++;
  1464. }
  1465. // deliver frame to system
  1466. rxd->rxd_os.skb = NULL;
  1467. skb_trim(skb, len);
  1468. skb->protocol = fddi_type_trans(skb, bp->dev);
  1469. netif_rx(skb);
  1470. HWM_RX_CHECK(smc, RX_LOW_WATERMARK);
  1471. return;
  1472. RequeueRxd:
  1473. pr_debug(KERN_INFO "Rx: re-queue RXD.\n");
  1474. mac_drv_requeue_rxd(smc, rxd, frag_count);
  1475. smc->os.MacStat.gen.rx_errors++; // Count receive packets
  1476. // not indicated.
  1477. } // mac_drv_rx_complete
  1478. /************************
  1479. *
  1480. * mac_drv_requeue_rxd
  1481. *
  1482. * The hardware module calls this function to request the OS-specific
  1483. * module to queue the receive buffer(s) represented by the pointer
  1484. * to the RxD and the frag_count into the receive queue again. This
  1485. * buffer was filled with an invalid frame or an SMT frame.
  1486. * Args
  1487. * smc - A pointer to the SMT context struct.
  1488. *
  1489. * rxd - A pointer to the first RxD which is used by the receive frame.
  1490. *
  1491. * frag_count - Count of RxDs used by the received frame.
  1492. * Out
  1493. * Nothing.
  1494. *
  1495. ************************/
  1496. void mac_drv_requeue_rxd(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
  1497. int frag_count)
  1498. {
  1499. volatile struct s_smt_fp_rxd *next_rxd;
  1500. volatile struct s_smt_fp_rxd *src_rxd;
  1501. struct sk_buff *skb;
  1502. int MaxFrameSize;
  1503. unsigned char *v_addr;
  1504. dma_addr_t b_addr;
  1505. if (frag_count != 1) // This is not allowed to happen.
  1506. printk("fddi: Multi-fragment requeue!\n");
  1507. MaxFrameSize = smc->os.MaxFrameSize;
  1508. src_rxd = rxd;
  1509. for (; frag_count > 0; frag_count--) {
  1510. next_rxd = src_rxd->rxd_next;
  1511. rxd = HWM_GET_CURR_RXD(smc);
  1512. skb = src_rxd->rxd_os.skb;
  1513. if (skb == NULL) { // this should not happen
  1514. pr_debug("Requeue with no skb in rxd!\n");
  1515. skb = alloc_skb(MaxFrameSize + 3, GFP_ATOMIC);
  1516. if (skb) {
  1517. // we got a skb
  1518. rxd->rxd_os.skb = skb;
  1519. skb_reserve(skb, 3);
  1520. skb_put(skb, MaxFrameSize);
  1521. v_addr = skb->data;
  1522. b_addr = pci_map_single(&smc->os.pdev,
  1523. v_addr,
  1524. MaxFrameSize,
  1525. PCI_DMA_FROMDEVICE);
  1526. rxd->rxd_os.dma_addr = b_addr;
  1527. } else {
  1528. // no skb available, use local buffer
  1529. pr_debug("Queueing invalid buffer!\n");
  1530. rxd->rxd_os.skb = NULL;
  1531. v_addr = smc->os.LocalRxBuffer;
  1532. b_addr = smc->os.LocalRxBufferDMA;
  1533. }
  1534. } else {
  1535. // we use skb from old rxd
  1536. rxd->rxd_os.skb = skb;
  1537. v_addr = skb->data;
  1538. b_addr = pci_map_single(&smc->os.pdev,
  1539. v_addr,
  1540. MaxFrameSize,
  1541. PCI_DMA_FROMDEVICE);
  1542. rxd->rxd_os.dma_addr = b_addr;
  1543. }
  1544. hwm_rx_frag(smc, v_addr, b_addr, MaxFrameSize,
  1545. FIRST_FRAG | LAST_FRAG);
  1546. src_rxd = next_rxd;
  1547. }
  1548. } // mac_drv_requeue_rxd
  1549. /************************
  1550. *
  1551. * mac_drv_fill_rxd
  1552. *
  1553. * The hardware module calls this function at initialization time
  1554. * to fill the RxD ring with receive buffers. It is also called by
  1555. * mac_drv_rx_complete if rx_free is large enough to queue some new
  1556. * receive buffers into the RxD ring. mac_drv_fill_rxd queues new
  1557. * receive buffers as long as enough RxDs and receive buffers are
  1558. * available.
  1559. * Args
  1560. * smc - A pointer to the SMT context struct.
  1561. * Out
  1562. * Nothing.
  1563. *
  1564. ************************/
  1565. void mac_drv_fill_rxd(struct s_smc *smc)
  1566. {
  1567. int MaxFrameSize;
  1568. unsigned char *v_addr;
  1569. unsigned long b_addr;
  1570. struct sk_buff *skb;
  1571. volatile struct s_smt_fp_rxd *rxd;
  1572. pr_debug(KERN_INFO "entering mac_drv_fill_rxd\n");
  1573. // Walk through the list of free receive buffers, passing receive
  1574. // buffers to the HWM as long as RXDs are available.
  1575. MaxFrameSize = smc->os.MaxFrameSize;
  1576. // Check if there is any RXD left.
  1577. while (HWM_GET_RX_FREE(smc) > 0) {
  1578. pr_debug(KERN_INFO ".\n");
  1579. rxd = HWM_GET_CURR_RXD(smc);
  1580. skb = alloc_skb(MaxFrameSize + 3, GFP_ATOMIC);
  1581. if (skb) {
  1582. // we got a skb
  1583. skb_reserve(skb, 3);
  1584. skb_put(skb, MaxFrameSize);
  1585. v_addr = skb->data;
  1586. b_addr = pci_map_single(&smc->os.pdev,
  1587. v_addr,
  1588. MaxFrameSize,
  1589. PCI_DMA_FROMDEVICE);
  1590. rxd->rxd_os.dma_addr = b_addr;
  1591. } else {
  1592. // no skb available, use local buffer
  1593. // System has run out of buffer memory, but we want to
  1594. // keep the receiver running in hope of better times.
  1595. // Multiple descriptors may point to this local buffer,
  1596. // so data in it must be considered invalid.
  1597. pr_debug("Queueing invalid buffer!\n");
  1598. v_addr = smc->os.LocalRxBuffer;
  1599. b_addr = smc->os.LocalRxBufferDMA;
  1600. }
  1601. rxd->rxd_os.skb = skb;
  1602. // Pass receive buffer to HWM.
  1603. hwm_rx_frag(smc, v_addr, b_addr, MaxFrameSize,
  1604. FIRST_FRAG | LAST_FRAG);
  1605. }
  1606. pr_debug(KERN_INFO "leaving mac_drv_fill_rxd\n");
  1607. } // mac_drv_fill_rxd
  1608. /************************
  1609. *
  1610. * mac_drv_clear_rxd
  1611. *
  1612. * The hardware module calls this function to release unused
  1613. * receive buffers.
  1614. * Args
  1615. * smc - A pointer to the SMT context struct.
  1616. *
  1617. * rxd - A pointer to the first RxD which is used by the receive buffer.
  1618. *
  1619. * frag_count - Count of RxDs used by the receive buffer.
  1620. * Out
  1621. * Nothing.
  1622. *
  1623. ************************/
  1624. void mac_drv_clear_rxd(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
  1625. int frag_count)
  1626. {
  1627. struct sk_buff *skb;
  1628. pr_debug("entering mac_drv_clear_rxd\n");
  1629. if (frag_count != 1) // This is not allowed to happen.
  1630. printk("fddi: Multi-fragment clear!\n");
  1631. for (; frag_count > 0; frag_count--) {
  1632. skb = rxd->rxd_os.skb;
  1633. if (skb != NULL) {
  1634. skfddi_priv *bp = &smc->os;
  1635. int MaxFrameSize = bp->MaxFrameSize;
  1636. pci_unmap_single(&bp->pdev, rxd->rxd_os.dma_addr,
  1637. MaxFrameSize, PCI_DMA_FROMDEVICE);
  1638. dev_kfree_skb(skb);
  1639. rxd->rxd_os.skb = NULL;
  1640. }
  1641. rxd = rxd->rxd_next; // Next RXD.
  1642. }
  1643. } // mac_drv_clear_rxd
  1644. /************************
  1645. *
  1646. * mac_drv_rx_init
  1647. *
  1648. * The hardware module calls this routine when an SMT or NSA frame of the
  1649. * local SMT should be delivered to the LLC layer.
  1650. *
  1651. * It is necessary to have this function, because there is no other way to
  1652. * copy the contents of SMT MBufs into receive buffers.
  1653. *
  1654. * mac_drv_rx_init allocates the required target memory for this frame,
  1655. * and receives the frame fragment by fragment by calling mac_drv_rx_frag.
  1656. * Args
  1657. * smc - A pointer to the SMT context struct.
  1658. *
  1659. * len - The length (in bytes) of the received frame (FC, DA, SA, Data).
  1660. *
  1661. * fc - The Frame Control field of the received frame.
  1662. *
  1663. * look_ahead - A pointer to the lookahead data buffer (may be NULL).
  1664. *
  1665. * la_len - The length of the lookahead data stored in the lookahead
  1666. * buffer (may be zero).
  1667. * Out
  1668. * Always returns zero (0).
  1669. *
  1670. ************************/
  1671. int mac_drv_rx_init(struct s_smc *smc, int len, int fc,
  1672. char *look_ahead, int la_len)
  1673. {
  1674. struct sk_buff *skb;
  1675. pr_debug("entering mac_drv_rx_init(len=%d)\n", len);
  1676. // "Received" a SMT or NSA frame of the local SMT.
  1677. if (len != la_len || len < FDDI_MAC_HDR_LEN || !look_ahead) {
  1678. pr_debug("fddi: Discard invalid local SMT frame\n");
  1679. pr_debug(" len=%d, la_len=%d, (ULONG) look_ahead=%08lXh.\n",
  1680. len, la_len, (unsigned long) look_ahead);
  1681. return (0);
  1682. }
  1683. skb = alloc_skb(len + 3, GFP_ATOMIC);
  1684. if (!skb) {
  1685. pr_debug("fddi: Local SMT: skb memory exhausted.\n");
  1686. return (0);
  1687. }
  1688. skb_reserve(skb, 3);
  1689. skb_put(skb, len);
  1690. skb_copy_to_linear_data(skb, look_ahead, len);
  1691. // deliver frame to system
  1692. skb->protocol = fddi_type_trans(skb, smc->os.dev);
  1693. netif_rx(skb);
  1694. return (0);
  1695. } // mac_drv_rx_init
  1696. /************************
  1697. *
  1698. * smt_timer_poll
  1699. *
  1700. * This routine is called periodically by the SMT module to clean up the
  1701. * driver.
  1702. *
  1703. * Return any queued frames back to the upper protocol layers if the ring
  1704. * is down.
  1705. * Args
  1706. * smc - A pointer to the SMT context struct.
  1707. * Out
  1708. * Nothing.
  1709. *
  1710. ************************/
  1711. void smt_timer_poll(struct s_smc *smc)
  1712. {
  1713. } // smt_timer_poll
  1714. /************************
  1715. *
  1716. * ring_status_indication
  1717. *
  1718. * This function indicates a change of the ring state.
  1719. * Args
  1720. * smc - A pointer to the SMT context struct.
  1721. *
  1722. * status - The current ring status.
  1723. * Out
  1724. * Nothing.
  1725. *
  1726. ************************/
  1727. void ring_status_indication(struct s_smc *smc, u_long status)
  1728. {
  1729. pr_debug("ring_status_indication( ");
  1730. if (status & RS_RES15)
  1731. pr_debug("RS_RES15 ");
  1732. if (status & RS_HARDERROR)
  1733. pr_debug("RS_HARDERROR ");
  1734. if (status & RS_SOFTERROR)
  1735. pr_debug("RS_SOFTERROR ");
  1736. if (status & RS_BEACON)
  1737. pr_debug("RS_BEACON ");
  1738. if (status & RS_PATHTEST)
  1739. pr_debug("RS_PATHTEST ");
  1740. if (status & RS_SELFTEST)
  1741. pr_debug("RS_SELFTEST ");
  1742. if (status & RS_RES9)
  1743. pr_debug("RS_RES9 ");
  1744. if (status & RS_DISCONNECT)
  1745. pr_debug("RS_DISCONNECT ");
  1746. if (status & RS_RES7)
  1747. pr_debug("RS_RES7 ");
  1748. if (status & RS_DUPADDR)
  1749. pr_debug("RS_DUPADDR ");
  1750. if (status & RS_NORINGOP)
  1751. pr_debug("RS_NORINGOP ");
  1752. if (status & RS_VERSION)
  1753. pr_debug("RS_VERSION ");
  1754. if (status & RS_STUCKBYPASSS)
  1755. pr_debug("RS_STUCKBYPASSS ");
  1756. if (status & RS_EVENT)
  1757. pr_debug("RS_EVENT ");
  1758. if (status & RS_RINGOPCHANGE)
  1759. pr_debug("RS_RINGOPCHANGE ");
  1760. if (status & RS_RES0)
  1761. pr_debug("RS_RES0 ");
  1762. pr_debug("]\n");
  1763. } // ring_status_indication
  1764. /************************
  1765. *
  1766. * smt_get_time
  1767. *
  1768. * Gets the current time from the system.
  1769. * Args
  1770. * None.
  1771. * Out
  1772. * The current time in TICKS_PER_SECOND.
  1773. *
  1774. * TICKS_PER_SECOND has the unit 'count of timer ticks per second'. It is
  1775. * defined in "targetos.h". The definition of TICKS_PER_SECOND must comply
  1776. * to the time returned by smt_get_time().
  1777. *
  1778. ************************/
  1779. unsigned long smt_get_time(void)
  1780. {
  1781. return jiffies;
  1782. } // smt_get_time
  1783. /************************
  1784. *
  1785. * smt_stat_counter
  1786. *
  1787. * Status counter update (ring_op, fifo full).
  1788. * Args
  1789. * smc - A pointer to the SMT context struct.
  1790. *
  1791. * stat - = 0: A ring operational change occurred.
  1792. * = 1: The FORMAC FIFO buffer is full / FIFO overflow.
  1793. * Out
  1794. * Nothing.
  1795. *
  1796. ************************/
  1797. void smt_stat_counter(struct s_smc *smc, int stat)
  1798. {
  1799. // BOOLEAN RingIsUp ;
  1800. pr_debug(KERN_INFO "smt_stat_counter\n");
  1801. switch (stat) {
  1802. case 0:
  1803. pr_debug(KERN_INFO "Ring operational change.\n");
  1804. break;
  1805. case 1:
  1806. pr_debug(KERN_INFO "Receive fifo overflow.\n");
  1807. smc->os.MacStat.gen.rx_errors++;
  1808. break;
  1809. default:
  1810. pr_debug(KERN_INFO "Unknown status (%d).\n", stat);
  1811. break;
  1812. }
  1813. } // smt_stat_counter
  1814. /************************
  1815. *
  1816. * cfm_state_change
  1817. *
  1818. * Sets CFM state in custom statistics.
  1819. * Args
  1820. * smc - A pointer to the SMT context struct.
  1821. *
  1822. * c_state - Possible values are:
  1823. *
  1824. * EC0_OUT, EC1_IN, EC2_TRACE, EC3_LEAVE, EC4_PATH_TEST,
  1825. * EC5_INSERT, EC6_CHECK, EC7_DEINSERT
  1826. * Out
  1827. * Nothing.
  1828. *
  1829. ************************/
  1830. void cfm_state_change(struct s_smc *smc, int c_state)
  1831. {
  1832. #ifdef DRIVERDEBUG
  1833. char *s;
  1834. switch (c_state) {
  1835. case SC0_ISOLATED:
  1836. s = "SC0_ISOLATED";
  1837. break;
  1838. case SC1_WRAP_A:
  1839. s = "SC1_WRAP_A";
  1840. break;
  1841. case SC2_WRAP_B:
  1842. s = "SC2_WRAP_B";
  1843. break;
  1844. case SC4_THRU_A:
  1845. s = "SC4_THRU_A";
  1846. break;
  1847. case SC5_THRU_B:
  1848. s = "SC5_THRU_B";
  1849. break;
  1850. case SC7_WRAP_S:
  1851. s = "SC7_WRAP_S";
  1852. break;
  1853. case SC9_C_WRAP_A:
  1854. s = "SC9_C_WRAP_A";
  1855. break;
  1856. case SC10_C_WRAP_B:
  1857. s = "SC10_C_WRAP_B";
  1858. break;
  1859. case SC11_C_WRAP_S:
  1860. s = "SC11_C_WRAP_S";
  1861. break;
  1862. default:
  1863. pr_debug(KERN_INFO "cfm_state_change: unknown %d\n", c_state);
  1864. return;
  1865. }
  1866. pr_debug(KERN_INFO "cfm_state_change: %s\n", s);
  1867. #endif // DRIVERDEBUG
  1868. } // cfm_state_change
  1869. /************************
  1870. *
  1871. * ecm_state_change
  1872. *
  1873. * Sets ECM state in custom statistics.
  1874. * Args
  1875. * smc - A pointer to the SMT context struct.
  1876. *
  1877. * e_state - Possible values are:
  1878. *
  1879. * SC0_ISOLATED, SC1_WRAP_A (5), SC2_WRAP_B (6), SC4_THRU_A (12),
  1880. * SC5_THRU_B (7), SC7_WRAP_S (8)
  1881. * Out
  1882. * Nothing.
  1883. *
  1884. ************************/
  1885. void ecm_state_change(struct s_smc *smc, int e_state)
  1886. {
  1887. #ifdef DRIVERDEBUG
  1888. char *s;
  1889. switch (e_state) {
  1890. case EC0_OUT:
  1891. s = "EC0_OUT";
  1892. break;
  1893. case EC1_IN:
  1894. s = "EC1_IN";
  1895. break;
  1896. case EC2_TRACE:
  1897. s = "EC2_TRACE";
  1898. break;
  1899. case EC3_LEAVE:
  1900. s = "EC3_LEAVE";
  1901. break;
  1902. case EC4_PATH_TEST:
  1903. s = "EC4_PATH_TEST";
  1904. break;
  1905. case EC5_INSERT:
  1906. s = "EC5_INSERT";
  1907. break;
  1908. case EC6_CHECK:
  1909. s = "EC6_CHECK";
  1910. break;
  1911. case EC7_DEINSERT:
  1912. s = "EC7_DEINSERT";
  1913. break;
  1914. default:
  1915. s = "unknown";
  1916. break;
  1917. }
  1918. pr_debug(KERN_INFO "ecm_state_change: %s\n", s);
  1919. #endif //DRIVERDEBUG
  1920. } // ecm_state_change
  1921. /************************
  1922. *
  1923. * rmt_state_change
  1924. *
  1925. * Sets RMT state in custom statistics.
  1926. * Args
  1927. * smc - A pointer to the SMT context struct.
  1928. *
  1929. * r_state - Possible values are:
  1930. *
  1931. * RM0_ISOLATED, RM1_NON_OP, RM2_RING_OP, RM3_DETECT,
  1932. * RM4_NON_OP_DUP, RM5_RING_OP_DUP, RM6_DIRECTED, RM7_TRACE
  1933. * Out
  1934. * Nothing.
  1935. *
  1936. ************************/
  1937. void rmt_state_change(struct s_smc *smc, int r_state)
  1938. {
  1939. #ifdef DRIVERDEBUG
  1940. char *s;
  1941. switch (r_state) {
  1942. case RM0_ISOLATED:
  1943. s = "RM0_ISOLATED";
  1944. break;
  1945. case RM1_NON_OP:
  1946. s = "RM1_NON_OP - not operational";
  1947. break;
  1948. case RM2_RING_OP:
  1949. s = "RM2_RING_OP - ring operational";
  1950. break;
  1951. case RM3_DETECT:
  1952. s = "RM3_DETECT - detect dupl addresses";
  1953. break;
  1954. case RM4_NON_OP_DUP:
  1955. s = "RM4_NON_OP_DUP - dupl. addr detected";
  1956. break;
  1957. case RM5_RING_OP_DUP:
  1958. s = "RM5_RING_OP_DUP - ring oper. with dupl. addr";
  1959. break;
  1960. case RM6_DIRECTED:
  1961. s = "RM6_DIRECTED - sending directed beacons";
  1962. break;
  1963. case RM7_TRACE:
  1964. s = "RM7_TRACE - trace initiated";
  1965. break;
  1966. default:
  1967. s = "unknown";
  1968. break;
  1969. }
  1970. pr_debug(KERN_INFO "[rmt_state_change: %s]\n", s);
  1971. #endif // DRIVERDEBUG
  1972. } // rmt_state_change
  1973. /************************
  1974. *
  1975. * drv_reset_indication
  1976. *
  1977. * This function is called by the SMT when it has detected a severe
  1978. * hardware problem. The driver should perform a reset on the adapter
  1979. * as soon as possible, but not from within this function.
  1980. * Args
  1981. * smc - A pointer to the SMT context struct.
  1982. * Out
  1983. * Nothing.
  1984. *
  1985. ************************/
  1986. void drv_reset_indication(struct s_smc *smc)
  1987. {
  1988. pr_debug(KERN_INFO "entering drv_reset_indication\n");
  1989. smc->os.ResetRequested = TRUE; // Set flag.
  1990. } // drv_reset_indication
  1991. static struct pci_driver skfddi_pci_driver = {
  1992. .name = "skfddi",
  1993. .id_table = skfddi_pci_tbl,
  1994. .probe = skfp_init_one,
  1995. .remove = __devexit_p(skfp_remove_one),
  1996. };
  1997. static int __init skfd_init(void)
  1998. {
  1999. return pci_register_driver(&skfddi_pci_driver);
  2000. }
  2001. static void __exit skfd_exit(void)
  2002. {
  2003. pci_unregister_driver(&skfddi_pci_driver);
  2004. }
  2005. module_init(skfd_init);
  2006. module_exit(skfd_exit);