skfddi.c 65 KB

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