skfddi.c 65 KB

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