skfddi.c 64 KB

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