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