skfddi.c 64 KB

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