skfddi.c 64 KB

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