skfddi.c 64 KB

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