ioc3-eth.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Driver for SGI's IOC3 based Ethernet cards as found in the PCI card.
  7. *
  8. * Copyright (C) 1999, 2000, 01, 03, 06 Ralf Baechle
  9. * Copyright (C) 1995, 1999, 2000, 2001 by Silicon Graphics, Inc.
  10. *
  11. * References:
  12. * o IOC3 ASIC specification 4.51, 1996-04-18
  13. * o IEEE 802.3 specification, 2000 edition
  14. * o DP38840A Specification, National Semiconductor, March 1997
  15. *
  16. * To do:
  17. *
  18. * o Handle allocation failures in ioc3_alloc_skb() more gracefully.
  19. * o Handle allocation failures in ioc3_init_rings().
  20. * o Use prefetching for large packets. What is a good lower limit for
  21. * prefetching?
  22. * o We're probably allocating a bit too much memory.
  23. * o Use hardware checksums.
  24. * o Convert to using a IOC3 meta driver.
  25. * o Which PHYs might possibly be attached to the IOC3 in real live,
  26. * which workarounds are required for them? Do we ever have Lucent's?
  27. * o For the 2.5 branch kill the mii-tool ioctls.
  28. */
  29. #define IOC3_NAME "ioc3-eth"
  30. #define IOC3_VERSION "2.6.3-4"
  31. #include <linux/init.h>
  32. #include <linux/delay.h>
  33. #include <linux/kernel.h>
  34. #include <linux/mm.h>
  35. #include <linux/errno.h>
  36. #include <linux/module.h>
  37. #include <linux/pci.h>
  38. #include <linux/crc32.h>
  39. #include <linux/mii.h>
  40. #include <linux/in.h>
  41. #include <linux/ip.h>
  42. #include <linux/tcp.h>
  43. #include <linux/udp.h>
  44. #include <linux/dma-mapping.h>
  45. #include <linux/gfp.h>
  46. #ifdef CONFIG_SERIAL_8250
  47. #include <linux/serial_core.h>
  48. #include <linux/serial_8250.h>
  49. #include <linux/serial_reg.h>
  50. #endif
  51. #include <linux/netdevice.h>
  52. #include <linux/etherdevice.h>
  53. #include <linux/ethtool.h>
  54. #include <linux/skbuff.h>
  55. #include <net/ip.h>
  56. #include <asm/byteorder.h>
  57. #include <asm/io.h>
  58. #include <asm/pgtable.h>
  59. #include <asm/uaccess.h>
  60. #include <asm/sn/types.h>
  61. #include <asm/sn/ioc3.h>
  62. #include <asm/pci/bridge.h>
  63. /*
  64. * 64 RX buffers. This is tunable in the range of 16 <= x < 512. The
  65. * value must be a power of two.
  66. */
  67. #define RX_BUFFS 64
  68. #define ETCSR_FD ((17<<ETCSR_IPGR2_SHIFT) | (11<<ETCSR_IPGR1_SHIFT) | 21)
  69. #define ETCSR_HD ((21<<ETCSR_IPGR2_SHIFT) | (21<<ETCSR_IPGR1_SHIFT) | 21)
  70. /* Private per NIC data of the driver. */
  71. struct ioc3_private {
  72. struct ioc3 *regs;
  73. unsigned long *rxr; /* pointer to receiver ring */
  74. struct ioc3_etxd *txr;
  75. struct sk_buff *rx_skbs[512];
  76. struct sk_buff *tx_skbs[128];
  77. int rx_ci; /* RX consumer index */
  78. int rx_pi; /* RX producer index */
  79. int tx_ci; /* TX consumer index */
  80. int tx_pi; /* TX producer index */
  81. int txqlen;
  82. u32 emcr, ehar_h, ehar_l;
  83. spinlock_t ioc3_lock;
  84. struct mii_if_info mii;
  85. struct pci_dev *pdev;
  86. /* Members used by autonegotiation */
  87. struct timer_list ioc3_timer;
  88. };
  89. static inline struct net_device *priv_netdev(struct ioc3_private *dev)
  90. {
  91. return (void *)dev - ((sizeof(struct net_device) + 31) & ~31);
  92. }
  93. static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
  94. static void ioc3_set_multicast_list(struct net_device *dev);
  95. static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev);
  96. static void ioc3_timeout(struct net_device *dev);
  97. static inline unsigned int ioc3_hash(const unsigned char *addr);
  98. static inline void ioc3_stop(struct ioc3_private *ip);
  99. static void ioc3_init(struct net_device *dev);
  100. static const char ioc3_str[] = "IOC3 Ethernet";
  101. static const struct ethtool_ops ioc3_ethtool_ops;
  102. /* We use this to acquire receive skb's that we can DMA directly into. */
  103. #define IOC3_CACHELINE 128UL
  104. static inline unsigned long aligned_rx_skb_addr(unsigned long addr)
  105. {
  106. return (~addr + 1) & (IOC3_CACHELINE - 1UL);
  107. }
  108. static inline struct sk_buff * ioc3_alloc_skb(unsigned long length,
  109. unsigned int gfp_mask)
  110. {
  111. struct sk_buff *skb;
  112. skb = alloc_skb(length + IOC3_CACHELINE - 1, gfp_mask);
  113. if (likely(skb)) {
  114. int offset = aligned_rx_skb_addr((unsigned long) skb->data);
  115. if (offset)
  116. skb_reserve(skb, offset);
  117. }
  118. return skb;
  119. }
  120. static inline unsigned long ioc3_map(void *ptr, unsigned long vdev)
  121. {
  122. #ifdef CONFIG_SGI_IP27
  123. vdev <<= 57; /* Shift to PCI64_ATTR_VIRTUAL */
  124. return vdev | (0xaUL << PCI64_ATTR_TARG_SHFT) | PCI64_ATTR_PREF |
  125. ((unsigned long)ptr & TO_PHYS_MASK);
  126. #else
  127. return virt_to_bus(ptr);
  128. #endif
  129. }
  130. /* BEWARE: The IOC3 documentation documents the size of rx buffers as
  131. 1644 while it's actually 1664. This one was nasty to track down ... */
  132. #define RX_OFFSET 10
  133. #define RX_BUF_ALLOC_SIZE (1664 + RX_OFFSET + IOC3_CACHELINE)
  134. /* DMA barrier to separate cached and uncached accesses. */
  135. #define BARRIER() \
  136. __asm__("sync" ::: "memory")
  137. #define IOC3_SIZE 0x100000
  138. /*
  139. * IOC3 is a big endian device
  140. *
  141. * Unorthodox but makes the users of these macros more readable - the pointer
  142. * to the IOC3's memory mapped registers is expected as struct ioc3 * ioc3
  143. * in the environment.
  144. */
  145. #define ioc3_r_mcr() be32_to_cpu(ioc3->mcr)
  146. #define ioc3_w_mcr(v) do { ioc3->mcr = cpu_to_be32(v); } while (0)
  147. #define ioc3_w_gpcr_s(v) do { ioc3->gpcr_s = cpu_to_be32(v); } while (0)
  148. #define ioc3_r_emcr() be32_to_cpu(ioc3->emcr)
  149. #define ioc3_w_emcr(v) do { ioc3->emcr = cpu_to_be32(v); } while (0)
  150. #define ioc3_r_eisr() be32_to_cpu(ioc3->eisr)
  151. #define ioc3_w_eisr(v) do { ioc3->eisr = cpu_to_be32(v); } while (0)
  152. #define ioc3_r_eier() be32_to_cpu(ioc3->eier)
  153. #define ioc3_w_eier(v) do { ioc3->eier = cpu_to_be32(v); } while (0)
  154. #define ioc3_r_ercsr() be32_to_cpu(ioc3->ercsr)
  155. #define ioc3_w_ercsr(v) do { ioc3->ercsr = cpu_to_be32(v); } while (0)
  156. #define ioc3_r_erbr_h() be32_to_cpu(ioc3->erbr_h)
  157. #define ioc3_w_erbr_h(v) do { ioc3->erbr_h = cpu_to_be32(v); } while (0)
  158. #define ioc3_r_erbr_l() be32_to_cpu(ioc3->erbr_l)
  159. #define ioc3_w_erbr_l(v) do { ioc3->erbr_l = cpu_to_be32(v); } while (0)
  160. #define ioc3_r_erbar() be32_to_cpu(ioc3->erbar)
  161. #define ioc3_w_erbar(v) do { ioc3->erbar = cpu_to_be32(v); } while (0)
  162. #define ioc3_r_ercir() be32_to_cpu(ioc3->ercir)
  163. #define ioc3_w_ercir(v) do { ioc3->ercir = cpu_to_be32(v); } while (0)
  164. #define ioc3_r_erpir() be32_to_cpu(ioc3->erpir)
  165. #define ioc3_w_erpir(v) do { ioc3->erpir = cpu_to_be32(v); } while (0)
  166. #define ioc3_r_ertr() be32_to_cpu(ioc3->ertr)
  167. #define ioc3_w_ertr(v) do { ioc3->ertr = cpu_to_be32(v); } while (0)
  168. #define ioc3_r_etcsr() be32_to_cpu(ioc3->etcsr)
  169. #define ioc3_w_etcsr(v) do { ioc3->etcsr = cpu_to_be32(v); } while (0)
  170. #define ioc3_r_ersr() be32_to_cpu(ioc3->ersr)
  171. #define ioc3_w_ersr(v) do { ioc3->ersr = cpu_to_be32(v); } while (0)
  172. #define ioc3_r_etcdc() be32_to_cpu(ioc3->etcdc)
  173. #define ioc3_w_etcdc(v) do { ioc3->etcdc = cpu_to_be32(v); } while (0)
  174. #define ioc3_r_ebir() be32_to_cpu(ioc3->ebir)
  175. #define ioc3_w_ebir(v) do { ioc3->ebir = cpu_to_be32(v); } while (0)
  176. #define ioc3_r_etbr_h() be32_to_cpu(ioc3->etbr_h)
  177. #define ioc3_w_etbr_h(v) do { ioc3->etbr_h = cpu_to_be32(v); } while (0)
  178. #define ioc3_r_etbr_l() be32_to_cpu(ioc3->etbr_l)
  179. #define ioc3_w_etbr_l(v) do { ioc3->etbr_l = cpu_to_be32(v); } while (0)
  180. #define ioc3_r_etcir() be32_to_cpu(ioc3->etcir)
  181. #define ioc3_w_etcir(v) do { ioc3->etcir = cpu_to_be32(v); } while (0)
  182. #define ioc3_r_etpir() be32_to_cpu(ioc3->etpir)
  183. #define ioc3_w_etpir(v) do { ioc3->etpir = cpu_to_be32(v); } while (0)
  184. #define ioc3_r_emar_h() be32_to_cpu(ioc3->emar_h)
  185. #define ioc3_w_emar_h(v) do { ioc3->emar_h = cpu_to_be32(v); } while (0)
  186. #define ioc3_r_emar_l() be32_to_cpu(ioc3->emar_l)
  187. #define ioc3_w_emar_l(v) do { ioc3->emar_l = cpu_to_be32(v); } while (0)
  188. #define ioc3_r_ehar_h() be32_to_cpu(ioc3->ehar_h)
  189. #define ioc3_w_ehar_h(v) do { ioc3->ehar_h = cpu_to_be32(v); } while (0)
  190. #define ioc3_r_ehar_l() be32_to_cpu(ioc3->ehar_l)
  191. #define ioc3_w_ehar_l(v) do { ioc3->ehar_l = cpu_to_be32(v); } while (0)
  192. #define ioc3_r_micr() be32_to_cpu(ioc3->micr)
  193. #define ioc3_w_micr(v) do { ioc3->micr = cpu_to_be32(v); } while (0)
  194. #define ioc3_r_midr_r() be32_to_cpu(ioc3->midr_r)
  195. #define ioc3_w_midr_r(v) do { ioc3->midr_r = cpu_to_be32(v); } while (0)
  196. #define ioc3_r_midr_w() be32_to_cpu(ioc3->midr_w)
  197. #define ioc3_w_midr_w(v) do { ioc3->midr_w = cpu_to_be32(v); } while (0)
  198. static inline u32 mcr_pack(u32 pulse, u32 sample)
  199. {
  200. return (pulse << 10) | (sample << 2);
  201. }
  202. static int nic_wait(struct ioc3 *ioc3)
  203. {
  204. u32 mcr;
  205. do {
  206. mcr = ioc3_r_mcr();
  207. } while (!(mcr & 2));
  208. return mcr & 1;
  209. }
  210. static int nic_reset(struct ioc3 *ioc3)
  211. {
  212. int presence;
  213. ioc3_w_mcr(mcr_pack(500, 65));
  214. presence = nic_wait(ioc3);
  215. ioc3_w_mcr(mcr_pack(0, 500));
  216. nic_wait(ioc3);
  217. return presence;
  218. }
  219. static inline int nic_read_bit(struct ioc3 *ioc3)
  220. {
  221. int result;
  222. ioc3_w_mcr(mcr_pack(6, 13));
  223. result = nic_wait(ioc3);
  224. ioc3_w_mcr(mcr_pack(0, 100));
  225. nic_wait(ioc3);
  226. return result;
  227. }
  228. static inline void nic_write_bit(struct ioc3 *ioc3, int bit)
  229. {
  230. if (bit)
  231. ioc3_w_mcr(mcr_pack(6, 110));
  232. else
  233. ioc3_w_mcr(mcr_pack(80, 30));
  234. nic_wait(ioc3);
  235. }
  236. /*
  237. * Read a byte from an iButton device
  238. */
  239. static u32 nic_read_byte(struct ioc3 *ioc3)
  240. {
  241. u32 result = 0;
  242. int i;
  243. for (i = 0; i < 8; i++)
  244. result = (result >> 1) | (nic_read_bit(ioc3) << 7);
  245. return result;
  246. }
  247. /*
  248. * Write a byte to an iButton device
  249. */
  250. static void nic_write_byte(struct ioc3 *ioc3, int byte)
  251. {
  252. int i, bit;
  253. for (i = 8; i; i--) {
  254. bit = byte & 1;
  255. byte >>= 1;
  256. nic_write_bit(ioc3, bit);
  257. }
  258. }
  259. static u64 nic_find(struct ioc3 *ioc3, int *last)
  260. {
  261. int a, b, index, disc;
  262. u64 address = 0;
  263. nic_reset(ioc3);
  264. /* Search ROM. */
  265. nic_write_byte(ioc3, 0xf0);
  266. /* Algorithm from ``Book of iButton Standards''. */
  267. for (index = 0, disc = 0; index < 64; index++) {
  268. a = nic_read_bit(ioc3);
  269. b = nic_read_bit(ioc3);
  270. if (a && b) {
  271. printk("NIC search failed (not fatal).\n");
  272. *last = 0;
  273. return 0;
  274. }
  275. if (!a && !b) {
  276. if (index == *last) {
  277. address |= 1UL << index;
  278. } else if (index > *last) {
  279. address &= ~(1UL << index);
  280. disc = index;
  281. } else if ((address & (1UL << index)) == 0)
  282. disc = index;
  283. nic_write_bit(ioc3, address & (1UL << index));
  284. continue;
  285. } else {
  286. if (a)
  287. address |= 1UL << index;
  288. else
  289. address &= ~(1UL << index);
  290. nic_write_bit(ioc3, a);
  291. continue;
  292. }
  293. }
  294. *last = disc;
  295. return address;
  296. }
  297. static int nic_init(struct ioc3 *ioc3)
  298. {
  299. const char *unknown = "unknown";
  300. const char *type = unknown;
  301. u8 crc;
  302. u8 serial[6];
  303. int save = 0, i;
  304. while (1) {
  305. u64 reg;
  306. reg = nic_find(ioc3, &save);
  307. switch (reg & 0xff) {
  308. case 0x91:
  309. type = "DS1981U";
  310. break;
  311. default:
  312. if (save == 0) {
  313. /* Let the caller try again. */
  314. return -1;
  315. }
  316. continue;
  317. }
  318. nic_reset(ioc3);
  319. /* Match ROM. */
  320. nic_write_byte(ioc3, 0x55);
  321. for (i = 0; i < 8; i++)
  322. nic_write_byte(ioc3, (reg >> (i << 3)) & 0xff);
  323. reg >>= 8; /* Shift out type. */
  324. for (i = 0; i < 6; i++) {
  325. serial[i] = reg & 0xff;
  326. reg >>= 8;
  327. }
  328. crc = reg & 0xff;
  329. break;
  330. }
  331. printk("Found %s NIC", type);
  332. if (type != unknown)
  333. printk (" registration number %pM, CRC %02x", serial, crc);
  334. printk(".\n");
  335. return 0;
  336. }
  337. /*
  338. * Read the NIC (Number-In-a-Can) device used to store the MAC address on
  339. * SN0 / SN00 nodeboards and PCI cards.
  340. */
  341. static void ioc3_get_eaddr_nic(struct ioc3_private *ip)
  342. {
  343. struct ioc3 *ioc3 = ip->regs;
  344. u8 nic[14];
  345. int tries = 2; /* There may be some problem with the battery? */
  346. int i;
  347. ioc3_w_gpcr_s(1 << 21);
  348. while (tries--) {
  349. if (!nic_init(ioc3))
  350. break;
  351. udelay(500);
  352. }
  353. if (tries < 0) {
  354. printk("Failed to read MAC address\n");
  355. return;
  356. }
  357. /* Read Memory. */
  358. nic_write_byte(ioc3, 0xf0);
  359. nic_write_byte(ioc3, 0x00);
  360. nic_write_byte(ioc3, 0x00);
  361. for (i = 13; i >= 0; i--)
  362. nic[i] = nic_read_byte(ioc3);
  363. for (i = 2; i < 8; i++)
  364. priv_netdev(ip)->dev_addr[i - 2] = nic[i];
  365. }
  366. /*
  367. * Ok, this is hosed by design. It's necessary to know what machine the
  368. * NIC is in in order to know how to read the NIC address. We also have
  369. * to know if it's a PCI card or a NIC in on the node board ...
  370. */
  371. static void ioc3_get_eaddr(struct ioc3_private *ip)
  372. {
  373. ioc3_get_eaddr_nic(ip);
  374. printk("Ethernet address is %pM.\n", priv_netdev(ip)->dev_addr);
  375. }
  376. static void __ioc3_set_mac_address(struct net_device *dev)
  377. {
  378. struct ioc3_private *ip = netdev_priv(dev);
  379. struct ioc3 *ioc3 = ip->regs;
  380. ioc3_w_emar_h((dev->dev_addr[5] << 8) | dev->dev_addr[4]);
  381. ioc3_w_emar_l((dev->dev_addr[3] << 24) | (dev->dev_addr[2] << 16) |
  382. (dev->dev_addr[1] << 8) | dev->dev_addr[0]);
  383. }
  384. static int ioc3_set_mac_address(struct net_device *dev, void *addr)
  385. {
  386. struct ioc3_private *ip = netdev_priv(dev);
  387. struct sockaddr *sa = addr;
  388. memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);
  389. spin_lock_irq(&ip->ioc3_lock);
  390. __ioc3_set_mac_address(dev);
  391. spin_unlock_irq(&ip->ioc3_lock);
  392. return 0;
  393. }
  394. /*
  395. * Caller must hold the ioc3_lock ever for MII readers. This is also
  396. * used to protect the transmitter side but it's low contention.
  397. */
  398. static int ioc3_mdio_read(struct net_device *dev, int phy, int reg)
  399. {
  400. struct ioc3_private *ip = netdev_priv(dev);
  401. struct ioc3 *ioc3 = ip->regs;
  402. while (ioc3_r_micr() & MICR_BUSY);
  403. ioc3_w_micr((phy << MICR_PHYADDR_SHIFT) | reg | MICR_READTRIG);
  404. while (ioc3_r_micr() & MICR_BUSY);
  405. return ioc3_r_midr_r() & MIDR_DATA_MASK;
  406. }
  407. static void ioc3_mdio_write(struct net_device *dev, int phy, int reg, int data)
  408. {
  409. struct ioc3_private *ip = netdev_priv(dev);
  410. struct ioc3 *ioc3 = ip->regs;
  411. while (ioc3_r_micr() & MICR_BUSY);
  412. ioc3_w_midr_w(data);
  413. ioc3_w_micr((phy << MICR_PHYADDR_SHIFT) | reg);
  414. while (ioc3_r_micr() & MICR_BUSY);
  415. }
  416. static int ioc3_mii_init(struct ioc3_private *ip);
  417. static struct net_device_stats *ioc3_get_stats(struct net_device *dev)
  418. {
  419. struct ioc3_private *ip = netdev_priv(dev);
  420. struct ioc3 *ioc3 = ip->regs;
  421. dev->stats.collisions += (ioc3_r_etcdc() & ETCDC_COLLCNT_MASK);
  422. return &dev->stats;
  423. }
  424. static void ioc3_tcpudp_checksum(struct sk_buff *skb, uint32_t hwsum, int len)
  425. {
  426. struct ethhdr *eh = eth_hdr(skb);
  427. uint32_t csum, ehsum;
  428. unsigned int proto;
  429. struct iphdr *ih;
  430. uint16_t *ew;
  431. unsigned char *cp;
  432. /*
  433. * Did hardware handle the checksum at all? The cases we can handle
  434. * are:
  435. *
  436. * - TCP and UDP checksums of IPv4 only.
  437. * - IPv6 would be doable but we keep that for later ...
  438. * - Only unfragmented packets. Did somebody already tell you
  439. * fragmentation is evil?
  440. * - don't care about packet size. Worst case when processing a
  441. * malformed packet we'll try to access the packet at ip header +
  442. * 64 bytes which is still inside the skb. Even in the unlikely
  443. * case where the checksum is right the higher layers will still
  444. * drop the packet as appropriate.
  445. */
  446. if (eh->h_proto != htons(ETH_P_IP))
  447. return;
  448. ih = (struct iphdr *) ((char *)eh + ETH_HLEN);
  449. if (ih->frag_off & htons(IP_MF | IP_OFFSET))
  450. return;
  451. proto = ih->protocol;
  452. if (proto != IPPROTO_TCP && proto != IPPROTO_UDP)
  453. return;
  454. /* Same as tx - compute csum of pseudo header */
  455. csum = hwsum +
  456. (ih->tot_len - (ih->ihl << 2)) +
  457. htons((uint16_t)ih->protocol) +
  458. (ih->saddr >> 16) + (ih->saddr & 0xffff) +
  459. (ih->daddr >> 16) + (ih->daddr & 0xffff);
  460. /* Sum up ethernet dest addr, src addr and protocol */
  461. ew = (uint16_t *) eh;
  462. ehsum = ew[0] + ew[1] + ew[2] + ew[3] + ew[4] + ew[5] + ew[6];
  463. ehsum = (ehsum & 0xffff) + (ehsum >> 16);
  464. ehsum = (ehsum & 0xffff) + (ehsum >> 16);
  465. csum += 0xffff ^ ehsum;
  466. /* In the next step we also subtract the 1's complement
  467. checksum of the trailing ethernet CRC. */
  468. cp = (char *)eh + len; /* points at trailing CRC */
  469. if (len & 1) {
  470. csum += 0xffff ^ (uint16_t) ((cp[1] << 8) | cp[0]);
  471. csum += 0xffff ^ (uint16_t) ((cp[3] << 8) | cp[2]);
  472. } else {
  473. csum += 0xffff ^ (uint16_t) ((cp[0] << 8) | cp[1]);
  474. csum += 0xffff ^ (uint16_t) ((cp[2] << 8) | cp[3]);
  475. }
  476. csum = (csum & 0xffff) + (csum >> 16);
  477. csum = (csum & 0xffff) + (csum >> 16);
  478. if (csum == 0xffff)
  479. skb->ip_summed = CHECKSUM_UNNECESSARY;
  480. }
  481. static inline void ioc3_rx(struct net_device *dev)
  482. {
  483. struct ioc3_private *ip = netdev_priv(dev);
  484. struct sk_buff *skb, *new_skb;
  485. struct ioc3 *ioc3 = ip->regs;
  486. int rx_entry, n_entry, len;
  487. struct ioc3_erxbuf *rxb;
  488. unsigned long *rxr;
  489. u32 w0, err;
  490. rxr = (unsigned long *) ip->rxr; /* Ring base */
  491. rx_entry = ip->rx_ci; /* RX consume index */
  492. n_entry = ip->rx_pi;
  493. skb = ip->rx_skbs[rx_entry];
  494. rxb = (struct ioc3_erxbuf *) (skb->data - RX_OFFSET);
  495. w0 = be32_to_cpu(rxb->w0);
  496. while (w0 & ERXBUF_V) {
  497. err = be32_to_cpu(rxb->err); /* It's valid ... */
  498. if (err & ERXBUF_GOODPKT) {
  499. len = ((w0 >> ERXBUF_BYTECNT_SHIFT) & 0x7ff) - 4;
  500. skb_trim(skb, len);
  501. skb->protocol = eth_type_trans(skb, dev);
  502. new_skb = ioc3_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC);
  503. if (!new_skb) {
  504. /* Ouch, drop packet and just recycle packet
  505. to keep the ring filled. */
  506. dev->stats.rx_dropped++;
  507. new_skb = skb;
  508. goto next;
  509. }
  510. if (likely(dev->features & NETIF_F_RXCSUM))
  511. ioc3_tcpudp_checksum(skb,
  512. w0 & ERXBUF_IPCKSUM_MASK, len);
  513. netif_rx(skb);
  514. ip->rx_skbs[rx_entry] = NULL; /* Poison */
  515. /* Because we reserve afterwards. */
  516. skb_put(new_skb, (1664 + RX_OFFSET));
  517. rxb = (struct ioc3_erxbuf *) new_skb->data;
  518. skb_reserve(new_skb, RX_OFFSET);
  519. dev->stats.rx_packets++; /* Statistics */
  520. dev->stats.rx_bytes += len;
  521. } else {
  522. /* The frame is invalid and the skb never
  523. reached the network layer so we can just
  524. recycle it. */
  525. new_skb = skb;
  526. dev->stats.rx_errors++;
  527. }
  528. if (err & ERXBUF_CRCERR) /* Statistics */
  529. dev->stats.rx_crc_errors++;
  530. if (err & ERXBUF_FRAMERR)
  531. dev->stats.rx_frame_errors++;
  532. next:
  533. ip->rx_skbs[n_entry] = new_skb;
  534. rxr[n_entry] = cpu_to_be64(ioc3_map(rxb, 1));
  535. rxb->w0 = 0; /* Clear valid flag */
  536. n_entry = (n_entry + 1) & 511; /* Update erpir */
  537. /* Now go on to the next ring entry. */
  538. rx_entry = (rx_entry + 1) & 511;
  539. skb = ip->rx_skbs[rx_entry];
  540. rxb = (struct ioc3_erxbuf *) (skb->data - RX_OFFSET);
  541. w0 = be32_to_cpu(rxb->w0);
  542. }
  543. ioc3_w_erpir((n_entry << 3) | ERPIR_ARM);
  544. ip->rx_pi = n_entry;
  545. ip->rx_ci = rx_entry;
  546. }
  547. static inline void ioc3_tx(struct net_device *dev)
  548. {
  549. struct ioc3_private *ip = netdev_priv(dev);
  550. unsigned long packets, bytes;
  551. struct ioc3 *ioc3 = ip->regs;
  552. int tx_entry, o_entry;
  553. struct sk_buff *skb;
  554. u32 etcir;
  555. spin_lock(&ip->ioc3_lock);
  556. etcir = ioc3_r_etcir();
  557. tx_entry = (etcir >> 7) & 127;
  558. o_entry = ip->tx_ci;
  559. packets = 0;
  560. bytes = 0;
  561. while (o_entry != tx_entry) {
  562. packets++;
  563. skb = ip->tx_skbs[o_entry];
  564. bytes += skb->len;
  565. dev_kfree_skb_irq(skb);
  566. ip->tx_skbs[o_entry] = NULL;
  567. o_entry = (o_entry + 1) & 127; /* Next */
  568. etcir = ioc3_r_etcir(); /* More pkts sent? */
  569. tx_entry = (etcir >> 7) & 127;
  570. }
  571. dev->stats.tx_packets += packets;
  572. dev->stats.tx_bytes += bytes;
  573. ip->txqlen -= packets;
  574. if (ip->txqlen < 128)
  575. netif_wake_queue(dev);
  576. ip->tx_ci = o_entry;
  577. spin_unlock(&ip->ioc3_lock);
  578. }
  579. /*
  580. * Deal with fatal IOC3 errors. This condition might be caused by a hard or
  581. * software problems, so we should try to recover
  582. * more gracefully if this ever happens. In theory we might be flooded
  583. * with such error interrupts if something really goes wrong, so we might
  584. * also consider to take the interface down.
  585. */
  586. static void ioc3_error(struct net_device *dev, u32 eisr)
  587. {
  588. struct ioc3_private *ip = netdev_priv(dev);
  589. unsigned char *iface = dev->name;
  590. spin_lock(&ip->ioc3_lock);
  591. if (eisr & EISR_RXOFLO)
  592. printk(KERN_ERR "%s: RX overflow.\n", iface);
  593. if (eisr & EISR_RXBUFOFLO)
  594. printk(KERN_ERR "%s: RX buffer overflow.\n", iface);
  595. if (eisr & EISR_RXMEMERR)
  596. printk(KERN_ERR "%s: RX PCI error.\n", iface);
  597. if (eisr & EISR_RXPARERR)
  598. printk(KERN_ERR "%s: RX SSRAM parity error.\n", iface);
  599. if (eisr & EISR_TXBUFUFLO)
  600. printk(KERN_ERR "%s: TX buffer underflow.\n", iface);
  601. if (eisr & EISR_TXMEMERR)
  602. printk(KERN_ERR "%s: TX PCI error.\n", iface);
  603. ioc3_stop(ip);
  604. ioc3_init(dev);
  605. ioc3_mii_init(ip);
  606. netif_wake_queue(dev);
  607. spin_unlock(&ip->ioc3_lock);
  608. }
  609. /* The interrupt handler does all of the Rx thread work and cleans up
  610. after the Tx thread. */
  611. static irqreturn_t ioc3_interrupt(int irq, void *_dev)
  612. {
  613. struct net_device *dev = (struct net_device *)_dev;
  614. struct ioc3_private *ip = netdev_priv(dev);
  615. struct ioc3 *ioc3 = ip->regs;
  616. const u32 enabled = EISR_RXTIMERINT | EISR_RXOFLO | EISR_RXBUFOFLO |
  617. EISR_RXMEMERR | EISR_RXPARERR | EISR_TXBUFUFLO |
  618. EISR_TXEXPLICIT | EISR_TXMEMERR;
  619. u32 eisr;
  620. eisr = ioc3_r_eisr() & enabled;
  621. ioc3_w_eisr(eisr);
  622. (void) ioc3_r_eisr(); /* Flush */
  623. if (eisr & (EISR_RXOFLO | EISR_RXBUFOFLO | EISR_RXMEMERR |
  624. EISR_RXPARERR | EISR_TXBUFUFLO | EISR_TXMEMERR))
  625. ioc3_error(dev, eisr);
  626. if (eisr & EISR_RXTIMERINT)
  627. ioc3_rx(dev);
  628. if (eisr & EISR_TXEXPLICIT)
  629. ioc3_tx(dev);
  630. return IRQ_HANDLED;
  631. }
  632. static inline void ioc3_setup_duplex(struct ioc3_private *ip)
  633. {
  634. struct ioc3 *ioc3 = ip->regs;
  635. if (ip->mii.full_duplex) {
  636. ioc3_w_etcsr(ETCSR_FD);
  637. ip->emcr |= EMCR_DUPLEX;
  638. } else {
  639. ioc3_w_etcsr(ETCSR_HD);
  640. ip->emcr &= ~EMCR_DUPLEX;
  641. }
  642. ioc3_w_emcr(ip->emcr);
  643. }
  644. static void ioc3_timer(unsigned long data)
  645. {
  646. struct ioc3_private *ip = (struct ioc3_private *) data;
  647. /* Print the link status if it has changed */
  648. mii_check_media(&ip->mii, 1, 0);
  649. ioc3_setup_duplex(ip);
  650. ip->ioc3_timer.expires = jiffies + ((12 * HZ)/10); /* 1.2s */
  651. add_timer(&ip->ioc3_timer);
  652. }
  653. /*
  654. * Try to find a PHY. There is no apparent relation between the MII addresses
  655. * in the SGI documentation and what we find in reality, so we simply probe
  656. * for the PHY. It seems IOC3 PHYs usually live on address 31. One of my
  657. * onboard IOC3s has the special oddity that probing doesn't seem to find it
  658. * yet the interface seems to work fine, so if probing fails we for now will
  659. * simply default to PHY 31 instead of bailing out.
  660. */
  661. static int ioc3_mii_init(struct ioc3_private *ip)
  662. {
  663. struct net_device *dev = priv_netdev(ip);
  664. int i, found = 0, res = 0;
  665. int ioc3_phy_workaround = 1;
  666. u16 word;
  667. for (i = 0; i < 32; i++) {
  668. word = ioc3_mdio_read(dev, i, MII_PHYSID1);
  669. if (word != 0xffff && word != 0x0000) {
  670. found = 1;
  671. break; /* Found a PHY */
  672. }
  673. }
  674. if (!found) {
  675. if (ioc3_phy_workaround)
  676. i = 31;
  677. else {
  678. ip->mii.phy_id = -1;
  679. res = -ENODEV;
  680. goto out;
  681. }
  682. }
  683. ip->mii.phy_id = i;
  684. out:
  685. return res;
  686. }
  687. static void ioc3_mii_start(struct ioc3_private *ip)
  688. {
  689. ip->ioc3_timer.expires = jiffies + (12 * HZ)/10; /* 1.2 sec. */
  690. ip->ioc3_timer.data = (unsigned long) ip;
  691. ip->ioc3_timer.function = ioc3_timer;
  692. add_timer(&ip->ioc3_timer);
  693. }
  694. static inline void ioc3_clean_rx_ring(struct ioc3_private *ip)
  695. {
  696. struct sk_buff *skb;
  697. int i;
  698. for (i = ip->rx_ci; i & 15; i++) {
  699. ip->rx_skbs[ip->rx_pi] = ip->rx_skbs[ip->rx_ci];
  700. ip->rxr[ip->rx_pi++] = ip->rxr[ip->rx_ci++];
  701. }
  702. ip->rx_pi &= 511;
  703. ip->rx_ci &= 511;
  704. for (i = ip->rx_ci; i != ip->rx_pi; i = (i+1) & 511) {
  705. struct ioc3_erxbuf *rxb;
  706. skb = ip->rx_skbs[i];
  707. rxb = (struct ioc3_erxbuf *) (skb->data - RX_OFFSET);
  708. rxb->w0 = 0;
  709. }
  710. }
  711. static inline void ioc3_clean_tx_ring(struct ioc3_private *ip)
  712. {
  713. struct sk_buff *skb;
  714. int i;
  715. for (i=0; i < 128; i++) {
  716. skb = ip->tx_skbs[i];
  717. if (skb) {
  718. ip->tx_skbs[i] = NULL;
  719. dev_kfree_skb_any(skb);
  720. }
  721. ip->txr[i].cmd = 0;
  722. }
  723. ip->tx_pi = 0;
  724. ip->tx_ci = 0;
  725. }
  726. static void ioc3_free_rings(struct ioc3_private *ip)
  727. {
  728. struct sk_buff *skb;
  729. int rx_entry, n_entry;
  730. if (ip->txr) {
  731. ioc3_clean_tx_ring(ip);
  732. free_pages((unsigned long)ip->txr, 2);
  733. ip->txr = NULL;
  734. }
  735. if (ip->rxr) {
  736. n_entry = ip->rx_ci;
  737. rx_entry = ip->rx_pi;
  738. while (n_entry != rx_entry) {
  739. skb = ip->rx_skbs[n_entry];
  740. if (skb)
  741. dev_kfree_skb_any(skb);
  742. n_entry = (n_entry + 1) & 511;
  743. }
  744. free_page((unsigned long)ip->rxr);
  745. ip->rxr = NULL;
  746. }
  747. }
  748. static void ioc3_alloc_rings(struct net_device *dev)
  749. {
  750. struct ioc3_private *ip = netdev_priv(dev);
  751. struct ioc3_erxbuf *rxb;
  752. unsigned long *rxr;
  753. int i;
  754. if (ip->rxr == NULL) {
  755. /* Allocate and initialize rx ring. 4kb = 512 entries */
  756. ip->rxr = (unsigned long *) get_zeroed_page(GFP_ATOMIC);
  757. rxr = (unsigned long *) ip->rxr;
  758. if (!rxr)
  759. printk("ioc3_alloc_rings(): get_zeroed_page() failed!\n");
  760. /* Now the rx buffers. The RX ring may be larger but
  761. we only allocate 16 buffers for now. Need to tune
  762. this for performance and memory later. */
  763. for (i = 0; i < RX_BUFFS; i++) {
  764. struct sk_buff *skb;
  765. skb = ioc3_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC);
  766. if (!skb) {
  767. show_free_areas(0);
  768. continue;
  769. }
  770. ip->rx_skbs[i] = skb;
  771. /* Because we reserve afterwards. */
  772. skb_put(skb, (1664 + RX_OFFSET));
  773. rxb = (struct ioc3_erxbuf *) skb->data;
  774. rxr[i] = cpu_to_be64(ioc3_map(rxb, 1));
  775. skb_reserve(skb, RX_OFFSET);
  776. }
  777. ip->rx_ci = 0;
  778. ip->rx_pi = RX_BUFFS;
  779. }
  780. if (ip->txr == NULL) {
  781. /* Allocate and initialize tx rings. 16kb = 128 bufs. */
  782. ip->txr = (struct ioc3_etxd *)__get_free_pages(GFP_KERNEL, 2);
  783. if (!ip->txr)
  784. printk("ioc3_alloc_rings(): __get_free_pages() failed!\n");
  785. ip->tx_pi = 0;
  786. ip->tx_ci = 0;
  787. }
  788. }
  789. static void ioc3_init_rings(struct net_device *dev)
  790. {
  791. struct ioc3_private *ip = netdev_priv(dev);
  792. struct ioc3 *ioc3 = ip->regs;
  793. unsigned long ring;
  794. ioc3_free_rings(ip);
  795. ioc3_alloc_rings(dev);
  796. ioc3_clean_rx_ring(ip);
  797. ioc3_clean_tx_ring(ip);
  798. /* Now the rx ring base, consume & produce registers. */
  799. ring = ioc3_map(ip->rxr, 0);
  800. ioc3_w_erbr_h(ring >> 32);
  801. ioc3_w_erbr_l(ring & 0xffffffff);
  802. ioc3_w_ercir(ip->rx_ci << 3);
  803. ioc3_w_erpir((ip->rx_pi << 3) | ERPIR_ARM);
  804. ring = ioc3_map(ip->txr, 0);
  805. ip->txqlen = 0; /* nothing queued */
  806. /* Now the tx ring base, consume & produce registers. */
  807. ioc3_w_etbr_h(ring >> 32);
  808. ioc3_w_etbr_l(ring & 0xffffffff);
  809. ioc3_w_etpir(ip->tx_pi << 7);
  810. ioc3_w_etcir(ip->tx_ci << 7);
  811. (void) ioc3_r_etcir(); /* Flush */
  812. }
  813. static inline void ioc3_ssram_disc(struct ioc3_private *ip)
  814. {
  815. struct ioc3 *ioc3 = ip->regs;
  816. volatile u32 *ssram0 = &ioc3->ssram[0x0000];
  817. volatile u32 *ssram1 = &ioc3->ssram[0x4000];
  818. unsigned int pattern = 0x5555;
  819. /* Assume the larger size SSRAM and enable parity checking */
  820. ioc3_w_emcr(ioc3_r_emcr() | (EMCR_BUFSIZ | EMCR_RAMPAR));
  821. *ssram0 = pattern;
  822. *ssram1 = ~pattern & IOC3_SSRAM_DM;
  823. if ((*ssram0 & IOC3_SSRAM_DM) != pattern ||
  824. (*ssram1 & IOC3_SSRAM_DM) != (~pattern & IOC3_SSRAM_DM)) {
  825. /* set ssram size to 64 KB */
  826. ip->emcr = EMCR_RAMPAR;
  827. ioc3_w_emcr(ioc3_r_emcr() & ~EMCR_BUFSIZ);
  828. } else
  829. ip->emcr = EMCR_BUFSIZ | EMCR_RAMPAR;
  830. }
  831. static void ioc3_init(struct net_device *dev)
  832. {
  833. struct ioc3_private *ip = netdev_priv(dev);
  834. struct ioc3 *ioc3 = ip->regs;
  835. del_timer_sync(&ip->ioc3_timer); /* Kill if running */
  836. ioc3_w_emcr(EMCR_RST); /* Reset */
  837. (void) ioc3_r_emcr(); /* Flush WB */
  838. udelay(4); /* Give it time ... */
  839. ioc3_w_emcr(0);
  840. (void) ioc3_r_emcr();
  841. /* Misc registers */
  842. #ifdef CONFIG_SGI_IP27
  843. ioc3_w_erbar(PCI64_ATTR_BAR >> 32); /* Barrier on last store */
  844. #else
  845. ioc3_w_erbar(0); /* Let PCI API get it right */
  846. #endif
  847. (void) ioc3_r_etcdc(); /* Clear on read */
  848. ioc3_w_ercsr(15); /* RX low watermark */
  849. ioc3_w_ertr(0); /* Interrupt immediately */
  850. __ioc3_set_mac_address(dev);
  851. ioc3_w_ehar_h(ip->ehar_h);
  852. ioc3_w_ehar_l(ip->ehar_l);
  853. ioc3_w_ersr(42); /* XXX should be random */
  854. ioc3_init_rings(dev);
  855. ip->emcr |= ((RX_OFFSET / 2) << EMCR_RXOFF_SHIFT) | EMCR_TXDMAEN |
  856. EMCR_TXEN | EMCR_RXDMAEN | EMCR_RXEN | EMCR_PADEN;
  857. ioc3_w_emcr(ip->emcr);
  858. ioc3_w_eier(EISR_RXTIMERINT | EISR_RXOFLO | EISR_RXBUFOFLO |
  859. EISR_RXMEMERR | EISR_RXPARERR | EISR_TXBUFUFLO |
  860. EISR_TXEXPLICIT | EISR_TXMEMERR);
  861. (void) ioc3_r_eier();
  862. }
  863. static inline void ioc3_stop(struct ioc3_private *ip)
  864. {
  865. struct ioc3 *ioc3 = ip->regs;
  866. ioc3_w_emcr(0); /* Shutup */
  867. ioc3_w_eier(0); /* Disable interrupts */
  868. (void) ioc3_r_eier(); /* Flush */
  869. }
  870. static int ioc3_open(struct net_device *dev)
  871. {
  872. struct ioc3_private *ip = netdev_priv(dev);
  873. if (request_irq(dev->irq, ioc3_interrupt, IRQF_SHARED, ioc3_str, dev)) {
  874. printk(KERN_ERR "%s: Can't get irq %d\n", dev->name, dev->irq);
  875. return -EAGAIN;
  876. }
  877. ip->ehar_h = 0;
  878. ip->ehar_l = 0;
  879. ioc3_init(dev);
  880. ioc3_mii_start(ip);
  881. netif_start_queue(dev);
  882. return 0;
  883. }
  884. static int ioc3_close(struct net_device *dev)
  885. {
  886. struct ioc3_private *ip = netdev_priv(dev);
  887. del_timer_sync(&ip->ioc3_timer);
  888. netif_stop_queue(dev);
  889. ioc3_stop(ip);
  890. free_irq(dev->irq, dev);
  891. ioc3_free_rings(ip);
  892. return 0;
  893. }
  894. /*
  895. * MENET cards have four IOC3 chips, which are attached to two sets of
  896. * PCI slot resources each: the primary connections are on slots
  897. * 0..3 and the secondaries are on 4..7
  898. *
  899. * All four ethernets are brought out to connectors; six serial ports
  900. * (a pair from each of the first three IOC3s) are brought out to
  901. * MiniDINs; all other subdevices are left swinging in the wind, leave
  902. * them disabled.
  903. */
  904. static int ioc3_adjacent_is_ioc3(struct pci_dev *pdev, int slot)
  905. {
  906. struct pci_dev *dev = pci_get_slot(pdev->bus, PCI_DEVFN(slot, 0));
  907. int ret = 0;
  908. if (dev) {
  909. if (dev->vendor == PCI_VENDOR_ID_SGI &&
  910. dev->device == PCI_DEVICE_ID_SGI_IOC3)
  911. ret = 1;
  912. pci_dev_put(dev);
  913. }
  914. return ret;
  915. }
  916. static int ioc3_is_menet(struct pci_dev *pdev)
  917. {
  918. return pdev->bus->parent == NULL &&
  919. ioc3_adjacent_is_ioc3(pdev, 0) &&
  920. ioc3_adjacent_is_ioc3(pdev, 1) &&
  921. ioc3_adjacent_is_ioc3(pdev, 2);
  922. }
  923. #ifdef CONFIG_SERIAL_8250
  924. /*
  925. * Note about serial ports and consoles:
  926. * For console output, everyone uses the IOC3 UARTA (offset 0x178)
  927. * connected to the master node (look in ip27_setup_console() and
  928. * ip27prom_console_write()).
  929. *
  930. * For serial (/dev/ttyS0 etc), we can not have hardcoded serial port
  931. * addresses on a partitioned machine. Since we currently use the ioc3
  932. * serial ports, we use dynamic serial port discovery that the serial.c
  933. * driver uses for pci/pnp ports (there is an entry for the SGI ioc3
  934. * boards in pci_boards[]). Unfortunately, UARTA's pio address is greater
  935. * than UARTB's, although UARTA on o200s has traditionally been known as
  936. * port 0. So, we just use one serial port from each ioc3 (since the
  937. * serial driver adds addresses to get to higher ports).
  938. *
  939. * The first one to do a register_console becomes the preferred console
  940. * (if there is no kernel command line console= directive). /dev/console
  941. * (ie 5, 1) is then "aliased" into the device number returned by the
  942. * "device" routine referred to in this console structure
  943. * (ip27prom_console_dev).
  944. *
  945. * Also look in ip27-pci.c:pci_fixup_ioc3() for some comments on working
  946. * around ioc3 oddities in this respect.
  947. *
  948. * The IOC3 serials use a 22MHz clock rate with an additional divider which
  949. * can be programmed in the SCR register if the DLAB bit is set.
  950. *
  951. * Register to interrupt zero because we share the interrupt with
  952. * the serial driver which we don't properly support yet.
  953. *
  954. * Can't use UPF_IOREMAP as the whole of IOC3 resources have already been
  955. * registered.
  956. */
  957. static void __devinit ioc3_8250_register(struct ioc3_uartregs __iomem *uart)
  958. {
  959. #define COSMISC_CONSTANT 6
  960. struct uart_port port = {
  961. .irq = 0,
  962. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  963. .iotype = UPIO_MEM,
  964. .regshift = 0,
  965. .uartclk = (22000000 << 1) / COSMISC_CONSTANT,
  966. .membase = (unsigned char __iomem *) uart,
  967. .mapbase = (unsigned long) uart,
  968. };
  969. unsigned char lcr;
  970. lcr = uart->iu_lcr;
  971. uart->iu_lcr = lcr | UART_LCR_DLAB;
  972. uart->iu_scr = COSMISC_CONSTANT,
  973. uart->iu_lcr = lcr;
  974. uart->iu_lcr;
  975. serial8250_register_port(&port);
  976. }
  977. static void __devinit ioc3_serial_probe(struct pci_dev *pdev, struct ioc3 *ioc3)
  978. {
  979. /*
  980. * We need to recognice and treat the fourth MENET serial as it
  981. * does not have an SuperIO chip attached to it, therefore attempting
  982. * to access it will result in bus errors. We call something an
  983. * MENET if PCI slot 0, 1, 2 and 3 of a master PCI bus all have an IOC3
  984. * in it. This is paranoid but we want to avoid blowing up on a
  985. * showhorn PCI box that happens to have 4 IOC3 cards in it so it's
  986. * not paranoid enough ...
  987. */
  988. if (ioc3_is_menet(pdev) && PCI_SLOT(pdev->devfn) == 3)
  989. return;
  990. /*
  991. * Switch IOC3 to PIO mode. It probably already was but let's be
  992. * paranoid
  993. */
  994. ioc3->gpcr_s = GPCR_UARTA_MODESEL | GPCR_UARTB_MODESEL;
  995. ioc3->gpcr_s;
  996. ioc3->gppr_6 = 0;
  997. ioc3->gppr_6;
  998. ioc3->gppr_7 = 0;
  999. ioc3->gppr_7;
  1000. ioc3->sscr_a = ioc3->sscr_a & ~SSCR_DMA_EN;
  1001. ioc3->sscr_a;
  1002. ioc3->sscr_b = ioc3->sscr_b & ~SSCR_DMA_EN;
  1003. ioc3->sscr_b;
  1004. /* Disable all SA/B interrupts except for SA/B_INT in SIO_IEC. */
  1005. ioc3->sio_iec &= ~ (SIO_IR_SA_TX_MT | SIO_IR_SA_RX_FULL |
  1006. SIO_IR_SA_RX_HIGH | SIO_IR_SA_RX_TIMER |
  1007. SIO_IR_SA_DELTA_DCD | SIO_IR_SA_DELTA_CTS |
  1008. SIO_IR_SA_TX_EXPLICIT | SIO_IR_SA_MEMERR);
  1009. ioc3->sio_iec |= SIO_IR_SA_INT;
  1010. ioc3->sscr_a = 0;
  1011. ioc3->sio_iec &= ~ (SIO_IR_SB_TX_MT | SIO_IR_SB_RX_FULL |
  1012. SIO_IR_SB_RX_HIGH | SIO_IR_SB_RX_TIMER |
  1013. SIO_IR_SB_DELTA_DCD | SIO_IR_SB_DELTA_CTS |
  1014. SIO_IR_SB_TX_EXPLICIT | SIO_IR_SB_MEMERR);
  1015. ioc3->sio_iec |= SIO_IR_SB_INT;
  1016. ioc3->sscr_b = 0;
  1017. ioc3_8250_register(&ioc3->sregs.uarta);
  1018. ioc3_8250_register(&ioc3->sregs.uartb);
  1019. }
  1020. #endif
  1021. static const struct net_device_ops ioc3_netdev_ops = {
  1022. .ndo_open = ioc3_open,
  1023. .ndo_stop = ioc3_close,
  1024. .ndo_start_xmit = ioc3_start_xmit,
  1025. .ndo_tx_timeout = ioc3_timeout,
  1026. .ndo_get_stats = ioc3_get_stats,
  1027. .ndo_set_multicast_list = ioc3_set_multicast_list,
  1028. .ndo_do_ioctl = ioc3_ioctl,
  1029. .ndo_validate_addr = eth_validate_addr,
  1030. .ndo_set_mac_address = ioc3_set_mac_address,
  1031. .ndo_change_mtu = eth_change_mtu,
  1032. };
  1033. static int __devinit ioc3_probe(struct pci_dev *pdev,
  1034. const struct pci_device_id *ent)
  1035. {
  1036. unsigned int sw_physid1, sw_physid2;
  1037. struct net_device *dev = NULL;
  1038. struct ioc3_private *ip;
  1039. struct ioc3 *ioc3;
  1040. unsigned long ioc3_base, ioc3_size;
  1041. u32 vendor, model, rev;
  1042. int err, pci_using_dac;
  1043. /* Configure DMA attributes. */
  1044. err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
  1045. if (!err) {
  1046. pci_using_dac = 1;
  1047. err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
  1048. if (err < 0) {
  1049. printk(KERN_ERR "%s: Unable to obtain 64 bit DMA "
  1050. "for consistent allocations\n", pci_name(pdev));
  1051. goto out;
  1052. }
  1053. } else {
  1054. err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
  1055. if (err) {
  1056. printk(KERN_ERR "%s: No usable DMA configuration, "
  1057. "aborting.\n", pci_name(pdev));
  1058. goto out;
  1059. }
  1060. pci_using_dac = 0;
  1061. }
  1062. if (pci_enable_device(pdev))
  1063. return -ENODEV;
  1064. dev = alloc_etherdev(sizeof(struct ioc3_private));
  1065. if (!dev) {
  1066. err = -ENOMEM;
  1067. goto out_disable;
  1068. }
  1069. if (pci_using_dac)
  1070. dev->features |= NETIF_F_HIGHDMA;
  1071. err = pci_request_regions(pdev, "ioc3");
  1072. if (err)
  1073. goto out_free;
  1074. SET_NETDEV_DEV(dev, &pdev->dev);
  1075. ip = netdev_priv(dev);
  1076. dev->irq = pdev->irq;
  1077. ioc3_base = pci_resource_start(pdev, 0);
  1078. ioc3_size = pci_resource_len(pdev, 0);
  1079. ioc3 = (struct ioc3 *) ioremap(ioc3_base, ioc3_size);
  1080. if (!ioc3) {
  1081. printk(KERN_CRIT "ioc3eth(%s): ioremap failed, goodbye.\n",
  1082. pci_name(pdev));
  1083. err = -ENOMEM;
  1084. goto out_res;
  1085. }
  1086. ip->regs = ioc3;
  1087. #ifdef CONFIG_SERIAL_8250
  1088. ioc3_serial_probe(pdev, ioc3);
  1089. #endif
  1090. spin_lock_init(&ip->ioc3_lock);
  1091. init_timer(&ip->ioc3_timer);
  1092. ioc3_stop(ip);
  1093. ioc3_init(dev);
  1094. ip->pdev = pdev;
  1095. ip->mii.phy_id_mask = 0x1f;
  1096. ip->mii.reg_num_mask = 0x1f;
  1097. ip->mii.dev = dev;
  1098. ip->mii.mdio_read = ioc3_mdio_read;
  1099. ip->mii.mdio_write = ioc3_mdio_write;
  1100. ioc3_mii_init(ip);
  1101. if (ip->mii.phy_id == -1) {
  1102. printk(KERN_CRIT "ioc3-eth(%s): Didn't find a PHY, goodbye.\n",
  1103. pci_name(pdev));
  1104. err = -ENODEV;
  1105. goto out_stop;
  1106. }
  1107. ioc3_mii_start(ip);
  1108. ioc3_ssram_disc(ip);
  1109. ioc3_get_eaddr(ip);
  1110. /* The IOC3-specific entries in the device structure. */
  1111. dev->watchdog_timeo = 5 * HZ;
  1112. dev->netdev_ops = &ioc3_netdev_ops;
  1113. dev->ethtool_ops = &ioc3_ethtool_ops;
  1114. dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
  1115. dev->features = NETIF_F_IP_CSUM;
  1116. sw_physid1 = ioc3_mdio_read(dev, ip->mii.phy_id, MII_PHYSID1);
  1117. sw_physid2 = ioc3_mdio_read(dev, ip->mii.phy_id, MII_PHYSID2);
  1118. err = register_netdev(dev);
  1119. if (err)
  1120. goto out_stop;
  1121. mii_check_media(&ip->mii, 1, 1);
  1122. ioc3_setup_duplex(ip);
  1123. vendor = (sw_physid1 << 12) | (sw_physid2 >> 4);
  1124. model = (sw_physid2 >> 4) & 0x3f;
  1125. rev = sw_physid2 & 0xf;
  1126. printk(KERN_INFO "%s: Using PHY %d, vendor 0x%x, model %d, "
  1127. "rev %d.\n", dev->name, ip->mii.phy_id, vendor, model, rev);
  1128. printk(KERN_INFO "%s: IOC3 SSRAM has %d kbyte.\n", dev->name,
  1129. ip->emcr & EMCR_BUFSIZ ? 128 : 64);
  1130. return 0;
  1131. out_stop:
  1132. ioc3_stop(ip);
  1133. del_timer_sync(&ip->ioc3_timer);
  1134. ioc3_free_rings(ip);
  1135. out_res:
  1136. pci_release_regions(pdev);
  1137. out_free:
  1138. free_netdev(dev);
  1139. out_disable:
  1140. /*
  1141. * We should call pci_disable_device(pdev); here if the IOC3 wasn't
  1142. * such a weird device ...
  1143. */
  1144. out:
  1145. return err;
  1146. }
  1147. static void __devexit ioc3_remove_one (struct pci_dev *pdev)
  1148. {
  1149. struct net_device *dev = pci_get_drvdata(pdev);
  1150. struct ioc3_private *ip = netdev_priv(dev);
  1151. struct ioc3 *ioc3 = ip->regs;
  1152. unregister_netdev(dev);
  1153. del_timer_sync(&ip->ioc3_timer);
  1154. iounmap(ioc3);
  1155. pci_release_regions(pdev);
  1156. free_netdev(dev);
  1157. /*
  1158. * We should call pci_disable_device(pdev); here if the IOC3 wasn't
  1159. * such a weird device ...
  1160. */
  1161. }
  1162. static DEFINE_PCI_DEVICE_TABLE(ioc3_pci_tbl) = {
  1163. { PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC3, PCI_ANY_ID, PCI_ANY_ID },
  1164. { 0 }
  1165. };
  1166. MODULE_DEVICE_TABLE(pci, ioc3_pci_tbl);
  1167. static struct pci_driver ioc3_driver = {
  1168. .name = "ioc3-eth",
  1169. .id_table = ioc3_pci_tbl,
  1170. .probe = ioc3_probe,
  1171. .remove = __devexit_p(ioc3_remove_one),
  1172. };
  1173. static int __init ioc3_init_module(void)
  1174. {
  1175. return pci_register_driver(&ioc3_driver);
  1176. }
  1177. static void __exit ioc3_cleanup_module(void)
  1178. {
  1179. pci_unregister_driver(&ioc3_driver);
  1180. }
  1181. static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
  1182. {
  1183. unsigned long data;
  1184. struct ioc3_private *ip = netdev_priv(dev);
  1185. struct ioc3 *ioc3 = ip->regs;
  1186. unsigned int len;
  1187. struct ioc3_etxd *desc;
  1188. uint32_t w0 = 0;
  1189. int produce;
  1190. /*
  1191. * IOC3 has a fairly simple minded checksumming hardware which simply
  1192. * adds up the 1's complement checksum for the entire packet and
  1193. * inserts it at an offset which can be specified in the descriptor
  1194. * into the transmit packet. This means we have to compensate for the
  1195. * MAC header which should not be summed and the TCP/UDP pseudo headers
  1196. * manually.
  1197. */
  1198. if (skb->ip_summed == CHECKSUM_PARTIAL) {
  1199. const struct iphdr *ih = ip_hdr(skb);
  1200. const int proto = ntohs(ih->protocol);
  1201. unsigned int csoff;
  1202. uint32_t csum, ehsum;
  1203. uint16_t *eh;
  1204. /* The MAC header. skb->mac seem the logic approach
  1205. to find the MAC header - except it's a NULL pointer ... */
  1206. eh = (uint16_t *) skb->data;
  1207. /* Sum up dest addr, src addr and protocol */
  1208. ehsum = eh[0] + eh[1] + eh[2] + eh[3] + eh[4] + eh[5] + eh[6];
  1209. /* Fold ehsum. can't use csum_fold which negates also ... */
  1210. ehsum = (ehsum & 0xffff) + (ehsum >> 16);
  1211. ehsum = (ehsum & 0xffff) + (ehsum >> 16);
  1212. /* Skip IP header; it's sum is always zero and was
  1213. already filled in by ip_output.c */
  1214. csum = csum_tcpudp_nofold(ih->saddr, ih->daddr,
  1215. ih->tot_len - (ih->ihl << 2),
  1216. proto, 0xffff ^ ehsum);
  1217. csum = (csum & 0xffff) + (csum >> 16); /* Fold again */
  1218. csum = (csum & 0xffff) + (csum >> 16);
  1219. csoff = ETH_HLEN + (ih->ihl << 2);
  1220. if (proto == IPPROTO_UDP) {
  1221. csoff += offsetof(struct udphdr, check);
  1222. udp_hdr(skb)->check = csum;
  1223. }
  1224. if (proto == IPPROTO_TCP) {
  1225. csoff += offsetof(struct tcphdr, check);
  1226. tcp_hdr(skb)->check = csum;
  1227. }
  1228. w0 = ETXD_DOCHECKSUM | (csoff << ETXD_CHKOFF_SHIFT);
  1229. }
  1230. spin_lock_irq(&ip->ioc3_lock);
  1231. data = (unsigned long) skb->data;
  1232. len = skb->len;
  1233. produce = ip->tx_pi;
  1234. desc = &ip->txr[produce];
  1235. if (len <= 104) {
  1236. /* Short packet, let's copy it directly into the ring. */
  1237. skb_copy_from_linear_data(skb, desc->data, skb->len);
  1238. if (len < ETH_ZLEN) {
  1239. /* Very short packet, pad with zeros at the end. */
  1240. memset(desc->data + len, 0, ETH_ZLEN - len);
  1241. len = ETH_ZLEN;
  1242. }
  1243. desc->cmd = cpu_to_be32(len | ETXD_INTWHENDONE | ETXD_D0V | w0);
  1244. desc->bufcnt = cpu_to_be32(len);
  1245. } else if ((data ^ (data + len - 1)) & 0x4000) {
  1246. unsigned long b2 = (data | 0x3fffUL) + 1UL;
  1247. unsigned long s1 = b2 - data;
  1248. unsigned long s2 = data + len - b2;
  1249. desc->cmd = cpu_to_be32(len | ETXD_INTWHENDONE |
  1250. ETXD_B1V | ETXD_B2V | w0);
  1251. desc->bufcnt = cpu_to_be32((s1 << ETXD_B1CNT_SHIFT) |
  1252. (s2 << ETXD_B2CNT_SHIFT));
  1253. desc->p1 = cpu_to_be64(ioc3_map(skb->data, 1));
  1254. desc->p2 = cpu_to_be64(ioc3_map((void *) b2, 1));
  1255. } else {
  1256. /* Normal sized packet that doesn't cross a page boundary. */
  1257. desc->cmd = cpu_to_be32(len | ETXD_INTWHENDONE | ETXD_B1V | w0);
  1258. desc->bufcnt = cpu_to_be32(len << ETXD_B1CNT_SHIFT);
  1259. desc->p1 = cpu_to_be64(ioc3_map(skb->data, 1));
  1260. }
  1261. BARRIER();
  1262. ip->tx_skbs[produce] = skb; /* Remember skb */
  1263. produce = (produce + 1) & 127;
  1264. ip->tx_pi = produce;
  1265. ioc3_w_etpir(produce << 7); /* Fire ... */
  1266. ip->txqlen++;
  1267. if (ip->txqlen >= 127)
  1268. netif_stop_queue(dev);
  1269. spin_unlock_irq(&ip->ioc3_lock);
  1270. return NETDEV_TX_OK;
  1271. }
  1272. static void ioc3_timeout(struct net_device *dev)
  1273. {
  1274. struct ioc3_private *ip = netdev_priv(dev);
  1275. printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name);
  1276. spin_lock_irq(&ip->ioc3_lock);
  1277. ioc3_stop(ip);
  1278. ioc3_init(dev);
  1279. ioc3_mii_init(ip);
  1280. ioc3_mii_start(ip);
  1281. spin_unlock_irq(&ip->ioc3_lock);
  1282. netif_wake_queue(dev);
  1283. }
  1284. /*
  1285. * Given a multicast ethernet address, this routine calculates the
  1286. * address's bit index in the logical address filter mask
  1287. */
  1288. static inline unsigned int ioc3_hash(const unsigned char *addr)
  1289. {
  1290. unsigned int temp = 0;
  1291. u32 crc;
  1292. int bits;
  1293. crc = ether_crc_le(ETH_ALEN, addr);
  1294. crc &= 0x3f; /* bit reverse lowest 6 bits for hash index */
  1295. for (bits = 6; --bits >= 0; ) {
  1296. temp <<= 1;
  1297. temp |= (crc & 0x1);
  1298. crc >>= 1;
  1299. }
  1300. return temp;
  1301. }
  1302. static void ioc3_get_drvinfo (struct net_device *dev,
  1303. struct ethtool_drvinfo *info)
  1304. {
  1305. struct ioc3_private *ip = netdev_priv(dev);
  1306. strcpy (info->driver, IOC3_NAME);
  1307. strcpy (info->version, IOC3_VERSION);
  1308. strcpy (info->bus_info, pci_name(ip->pdev));
  1309. }
  1310. static int ioc3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  1311. {
  1312. struct ioc3_private *ip = netdev_priv(dev);
  1313. int rc;
  1314. spin_lock_irq(&ip->ioc3_lock);
  1315. rc = mii_ethtool_gset(&ip->mii, cmd);
  1316. spin_unlock_irq(&ip->ioc3_lock);
  1317. return rc;
  1318. }
  1319. static int ioc3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  1320. {
  1321. struct ioc3_private *ip = netdev_priv(dev);
  1322. int rc;
  1323. spin_lock_irq(&ip->ioc3_lock);
  1324. rc = mii_ethtool_sset(&ip->mii, cmd);
  1325. spin_unlock_irq(&ip->ioc3_lock);
  1326. return rc;
  1327. }
  1328. static int ioc3_nway_reset(struct net_device *dev)
  1329. {
  1330. struct ioc3_private *ip = netdev_priv(dev);
  1331. int rc;
  1332. spin_lock_irq(&ip->ioc3_lock);
  1333. rc = mii_nway_restart(&ip->mii);
  1334. spin_unlock_irq(&ip->ioc3_lock);
  1335. return rc;
  1336. }
  1337. static u32 ioc3_get_link(struct net_device *dev)
  1338. {
  1339. struct ioc3_private *ip = netdev_priv(dev);
  1340. int rc;
  1341. spin_lock_irq(&ip->ioc3_lock);
  1342. rc = mii_link_ok(&ip->mii);
  1343. spin_unlock_irq(&ip->ioc3_lock);
  1344. return rc;
  1345. }
  1346. static const struct ethtool_ops ioc3_ethtool_ops = {
  1347. .get_drvinfo = ioc3_get_drvinfo,
  1348. .get_settings = ioc3_get_settings,
  1349. .set_settings = ioc3_set_settings,
  1350. .nway_reset = ioc3_nway_reset,
  1351. .get_link = ioc3_get_link,
  1352. };
  1353. static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  1354. {
  1355. struct ioc3_private *ip = netdev_priv(dev);
  1356. int rc;
  1357. spin_lock_irq(&ip->ioc3_lock);
  1358. rc = generic_mii_ioctl(&ip->mii, if_mii(rq), cmd, NULL);
  1359. spin_unlock_irq(&ip->ioc3_lock);
  1360. return rc;
  1361. }
  1362. static void ioc3_set_multicast_list(struct net_device *dev)
  1363. {
  1364. struct netdev_hw_addr *ha;
  1365. struct ioc3_private *ip = netdev_priv(dev);
  1366. struct ioc3 *ioc3 = ip->regs;
  1367. u64 ehar = 0;
  1368. netif_stop_queue(dev); /* Lock out others. */
  1369. if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
  1370. ip->emcr |= EMCR_PROMISC;
  1371. ioc3_w_emcr(ip->emcr);
  1372. (void) ioc3_r_emcr();
  1373. } else {
  1374. ip->emcr &= ~EMCR_PROMISC;
  1375. ioc3_w_emcr(ip->emcr); /* Clear promiscuous. */
  1376. (void) ioc3_r_emcr();
  1377. if ((dev->flags & IFF_ALLMULTI) ||
  1378. (netdev_mc_count(dev) > 64)) {
  1379. /* Too many for hashing to make sense or we want all
  1380. multicast packets anyway, so skip computing all the
  1381. hashes and just accept all packets. */
  1382. ip->ehar_h = 0xffffffff;
  1383. ip->ehar_l = 0xffffffff;
  1384. } else {
  1385. netdev_for_each_mc_addr(ha, dev) {
  1386. char *addr = ha->addr;
  1387. if (!(*addr & 1))
  1388. continue;
  1389. ehar |= (1UL << ioc3_hash(addr));
  1390. }
  1391. ip->ehar_h = ehar >> 32;
  1392. ip->ehar_l = ehar & 0xffffffff;
  1393. }
  1394. ioc3_w_ehar_h(ip->ehar_h);
  1395. ioc3_w_ehar_l(ip->ehar_l);
  1396. }
  1397. netif_wake_queue(dev); /* Let us get going again. */
  1398. }
  1399. MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
  1400. MODULE_DESCRIPTION("SGI IOC3 Ethernet driver");
  1401. MODULE_LICENSE("GPL");
  1402. module_init(ioc3_init_module);
  1403. module_exit(ioc3_cleanup_module);