skfddi.c 64 KB

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