lcs.c 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344
  1. /*
  2. * linux/drivers/s390/net/lcs.c
  3. *
  4. * Linux for S/390 Lan Channel Station Network Driver
  5. *
  6. * Copyright (C) 1999-2001 IBM Deutschland Entwicklung GmbH,
  7. * IBM Corporation
  8. * Author(s): Original Code written by
  9. * DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
  10. * Rewritten by
  11. * Frank Pavlic (fpavlic@de.ibm.com) and
  12. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2, or (at your option)
  17. * any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. */
  28. #include <linux/module.h>
  29. #include <linux/if.h>
  30. #include <linux/netdevice.h>
  31. #include <linux/etherdevice.h>
  32. #include <linux/trdevice.h>
  33. #include <linux/fddidevice.h>
  34. #include <linux/inetdevice.h>
  35. #include <linux/in.h>
  36. #include <linux/igmp.h>
  37. #include <linux/delay.h>
  38. #include <net/arp.h>
  39. #include <net/ip.h>
  40. #include <asm/debug.h>
  41. #include <asm/idals.h>
  42. #include <asm/timex.h>
  43. #include <linux/device.h>
  44. #include <asm/ccwgroup.h>
  45. #include "lcs.h"
  46. #include "cu3088.h"
  47. #if !defined(CONFIG_NET_ETHERNET) && \
  48. !defined(CONFIG_TR) && !defined(CONFIG_FDDI)
  49. #error Cannot compile lcs.c without some net devices switched on.
  50. #endif
  51. /**
  52. * initialization string for output
  53. */
  54. static char version[] __initdata = "LCS driver";
  55. static char debug_buffer[255];
  56. /**
  57. * Some prototypes.
  58. */
  59. static void lcs_tasklet(unsigned long);
  60. static void lcs_start_kernel_thread(struct lcs_card *card);
  61. static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *);
  62. static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *);
  63. /**
  64. * Debug Facility Stuff
  65. */
  66. static debug_info_t *lcs_dbf_setup;
  67. static debug_info_t *lcs_dbf_trace;
  68. /**
  69. * LCS Debug Facility functions
  70. */
  71. static void
  72. lcs_unregister_debug_facility(void)
  73. {
  74. if (lcs_dbf_setup)
  75. debug_unregister(lcs_dbf_setup);
  76. if (lcs_dbf_trace)
  77. debug_unregister(lcs_dbf_trace);
  78. }
  79. static int
  80. lcs_register_debug_facility(void)
  81. {
  82. lcs_dbf_setup = debug_register("lcs_setup", 2, 1, 8);
  83. lcs_dbf_trace = debug_register("lcs_trace", 2, 2, 8);
  84. if (lcs_dbf_setup == NULL || lcs_dbf_trace == NULL) {
  85. PRINT_ERR("Not enough memory for debug facility.\n");
  86. lcs_unregister_debug_facility();
  87. return -ENOMEM;
  88. }
  89. debug_register_view(lcs_dbf_setup, &debug_hex_ascii_view);
  90. debug_set_level(lcs_dbf_setup, 4);
  91. debug_register_view(lcs_dbf_trace, &debug_hex_ascii_view);
  92. debug_set_level(lcs_dbf_trace, 4);
  93. return 0;
  94. }
  95. /**
  96. * Allocate io buffers.
  97. */
  98. static int
  99. lcs_alloc_channel(struct lcs_channel *channel)
  100. {
  101. int cnt;
  102. LCS_DBF_TEXT(2, setup, "ichalloc");
  103. for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
  104. /* alloc memory fo iobuffer */
  105. channel->iob[cnt].data = (void *)
  106. kmalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL);
  107. if (channel->iob[cnt].data == NULL)
  108. break;
  109. memset(channel->iob[cnt].data, 0, LCS_IOBUFFERSIZE);
  110. channel->iob[cnt].state = BUF_STATE_EMPTY;
  111. }
  112. if (cnt < LCS_NUM_BUFFS) {
  113. /* Not all io buffers could be allocated. */
  114. LCS_DBF_TEXT(2, setup, "echalloc");
  115. while (cnt-- > 0)
  116. kfree(channel->iob[cnt].data);
  117. return -ENOMEM;
  118. }
  119. return 0;
  120. }
  121. /**
  122. * Free io buffers.
  123. */
  124. static void
  125. lcs_free_channel(struct lcs_channel *channel)
  126. {
  127. int cnt;
  128. LCS_DBF_TEXT(2, setup, "ichfree");
  129. for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
  130. kfree(channel->iob[cnt].data);
  131. channel->iob[cnt].data = NULL;
  132. }
  133. }
  134. /*
  135. * Cleanup channel.
  136. */
  137. static void
  138. lcs_cleanup_channel(struct lcs_channel *channel)
  139. {
  140. LCS_DBF_TEXT(3, setup, "cleanch");
  141. /* Kill write channel tasklets. */
  142. tasklet_kill(&channel->irq_tasklet);
  143. /* Free channel buffers. */
  144. lcs_free_channel(channel);
  145. }
  146. /**
  147. * LCS free memory for card and channels.
  148. */
  149. static void
  150. lcs_free_card(struct lcs_card *card)
  151. {
  152. LCS_DBF_TEXT(2, setup, "remcard");
  153. LCS_DBF_HEX(2, setup, &card, sizeof(void*));
  154. kfree(card);
  155. }
  156. /**
  157. * LCS alloc memory for card and channels
  158. */
  159. static struct lcs_card *
  160. lcs_alloc_card(void)
  161. {
  162. struct lcs_card *card;
  163. int rc;
  164. LCS_DBF_TEXT(2, setup, "alloclcs");
  165. card = kmalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA);
  166. if (card == NULL)
  167. return NULL;
  168. memset(card, 0, sizeof(struct lcs_card));
  169. card->lan_type = LCS_FRAME_TYPE_AUTO;
  170. card->pkt_seq = 0;
  171. card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT;
  172. /* Allocate io buffers for the read channel. */
  173. rc = lcs_alloc_channel(&card->read);
  174. if (rc){
  175. LCS_DBF_TEXT(2, setup, "iccwerr");
  176. lcs_free_card(card);
  177. return NULL;
  178. }
  179. /* Allocate io buffers for the write channel. */
  180. rc = lcs_alloc_channel(&card->write);
  181. if (rc) {
  182. LCS_DBF_TEXT(2, setup, "iccwerr");
  183. lcs_cleanup_channel(&card->read);
  184. lcs_free_card(card);
  185. return NULL;
  186. }
  187. #ifdef CONFIG_IP_MULTICAST
  188. INIT_LIST_HEAD(&card->ipm_list);
  189. #endif
  190. LCS_DBF_HEX(2, setup, &card, sizeof(void*));
  191. return card;
  192. }
  193. /*
  194. * Setup read channel.
  195. */
  196. static void
  197. lcs_setup_read_ccws(struct lcs_card *card)
  198. {
  199. int cnt;
  200. LCS_DBF_TEXT(2, setup, "ireadccw");
  201. /* Setup read ccws. */
  202. memset(card->read.ccws, 0, sizeof (struct ccw1) * (LCS_NUM_BUFFS + 1));
  203. for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
  204. card->read.ccws[cnt].cmd_code = LCS_CCW_READ;
  205. card->read.ccws[cnt].count = LCS_IOBUFFERSIZE;
  206. card->read.ccws[cnt].flags =
  207. CCW_FLAG_CC | CCW_FLAG_SLI | CCW_FLAG_PCI;
  208. /*
  209. * Note: we have allocated the buffer with GFP_DMA, so
  210. * we do not need to do set_normalized_cda.
  211. */
  212. card->read.ccws[cnt].cda =
  213. (__u32) __pa(card->read.iob[cnt].data);
  214. ((struct lcs_header *)
  215. card->read.iob[cnt].data)->offset = LCS_ILLEGAL_OFFSET;
  216. card->read.iob[cnt].callback = lcs_get_frames_cb;
  217. card->read.iob[cnt].state = BUF_STATE_READY;
  218. card->read.iob[cnt].count = LCS_IOBUFFERSIZE;
  219. }
  220. card->read.ccws[0].flags &= ~CCW_FLAG_PCI;
  221. card->read.ccws[LCS_NUM_BUFFS - 1].flags &= ~CCW_FLAG_PCI;
  222. card->read.ccws[LCS_NUM_BUFFS - 1].flags |= CCW_FLAG_SUSPEND;
  223. /* Last ccw is a tic (transfer in channel). */
  224. card->read.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER;
  225. card->read.ccws[LCS_NUM_BUFFS].cda =
  226. (__u32) __pa(card->read.ccws);
  227. /* Setg initial state of the read channel. */
  228. card->read.state = CH_STATE_INIT;
  229. card->read.io_idx = 0;
  230. card->read.buf_idx = 0;
  231. }
  232. static void
  233. lcs_setup_read(struct lcs_card *card)
  234. {
  235. LCS_DBF_TEXT(3, setup, "initread");
  236. lcs_setup_read_ccws(card);
  237. /* Initialize read channel tasklet. */
  238. card->read.irq_tasklet.data = (unsigned long) &card->read;
  239. card->read.irq_tasklet.func = lcs_tasklet;
  240. /* Initialize waitqueue. */
  241. init_waitqueue_head(&card->read.wait_q);
  242. }
  243. /*
  244. * Setup write channel.
  245. */
  246. static void
  247. lcs_setup_write_ccws(struct lcs_card *card)
  248. {
  249. int cnt;
  250. LCS_DBF_TEXT(3, setup, "iwritccw");
  251. /* Setup write ccws. */
  252. memset(card->write.ccws, 0, sizeof(struct ccw1) * LCS_NUM_BUFFS + 1);
  253. for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
  254. card->write.ccws[cnt].cmd_code = LCS_CCW_WRITE;
  255. card->write.ccws[cnt].count = 0;
  256. card->write.ccws[cnt].flags =
  257. CCW_FLAG_SUSPEND | CCW_FLAG_CC | CCW_FLAG_SLI;
  258. /*
  259. * Note: we have allocated the buffer with GFP_DMA, so
  260. * we do not need to do set_normalized_cda.
  261. */
  262. card->write.ccws[cnt].cda =
  263. (__u32) __pa(card->write.iob[cnt].data);
  264. }
  265. /* Last ccw is a tic (transfer in channel). */
  266. card->write.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER;
  267. card->write.ccws[LCS_NUM_BUFFS].cda =
  268. (__u32) __pa(card->write.ccws);
  269. /* Set initial state of the write channel. */
  270. card->read.state = CH_STATE_INIT;
  271. card->write.io_idx = 0;
  272. card->write.buf_idx = 0;
  273. }
  274. static void
  275. lcs_setup_write(struct lcs_card *card)
  276. {
  277. LCS_DBF_TEXT(3, setup, "initwrit");
  278. lcs_setup_write_ccws(card);
  279. /* Initialize write channel tasklet. */
  280. card->write.irq_tasklet.data = (unsigned long) &card->write;
  281. card->write.irq_tasklet.func = lcs_tasklet;
  282. /* Initialize waitqueue. */
  283. init_waitqueue_head(&card->write.wait_q);
  284. }
  285. static void
  286. lcs_set_allowed_threads(struct lcs_card *card, unsigned long threads)
  287. {
  288. unsigned long flags;
  289. spin_lock_irqsave(&card->mask_lock, flags);
  290. card->thread_allowed_mask = threads;
  291. spin_unlock_irqrestore(&card->mask_lock, flags);
  292. wake_up(&card->wait_q);
  293. }
  294. static inline int
  295. lcs_threads_running(struct lcs_card *card, unsigned long threads)
  296. {
  297. unsigned long flags;
  298. int rc = 0;
  299. spin_lock_irqsave(&card->mask_lock, flags);
  300. rc = (card->thread_running_mask & threads);
  301. spin_unlock_irqrestore(&card->mask_lock, flags);
  302. return rc;
  303. }
  304. static int
  305. lcs_wait_for_threads(struct lcs_card *card, unsigned long threads)
  306. {
  307. return wait_event_interruptible(card->wait_q,
  308. lcs_threads_running(card, threads) == 0);
  309. }
  310. static inline int
  311. lcs_set_thread_start_bit(struct lcs_card *card, unsigned long thread)
  312. {
  313. unsigned long flags;
  314. spin_lock_irqsave(&card->mask_lock, flags);
  315. if ( !(card->thread_allowed_mask & thread) ||
  316. (card->thread_start_mask & thread) ) {
  317. spin_unlock_irqrestore(&card->mask_lock, flags);
  318. return -EPERM;
  319. }
  320. card->thread_start_mask |= thread;
  321. spin_unlock_irqrestore(&card->mask_lock, flags);
  322. return 0;
  323. }
  324. static void
  325. lcs_clear_thread_running_bit(struct lcs_card *card, unsigned long thread)
  326. {
  327. unsigned long flags;
  328. spin_lock_irqsave(&card->mask_lock, flags);
  329. card->thread_running_mask &= ~thread;
  330. spin_unlock_irqrestore(&card->mask_lock, flags);
  331. wake_up(&card->wait_q);
  332. }
  333. static inline int
  334. __lcs_do_run_thread(struct lcs_card *card, unsigned long thread)
  335. {
  336. unsigned long flags;
  337. int rc = 0;
  338. spin_lock_irqsave(&card->mask_lock, flags);
  339. if (card->thread_start_mask & thread){
  340. if ((card->thread_allowed_mask & thread) &&
  341. !(card->thread_running_mask & thread)){
  342. rc = 1;
  343. card->thread_start_mask &= ~thread;
  344. card->thread_running_mask |= thread;
  345. } else
  346. rc = -EPERM;
  347. }
  348. spin_unlock_irqrestore(&card->mask_lock, flags);
  349. return rc;
  350. }
  351. static int
  352. lcs_do_run_thread(struct lcs_card *card, unsigned long thread)
  353. {
  354. int rc = 0;
  355. wait_event(card->wait_q,
  356. (rc = __lcs_do_run_thread(card, thread)) >= 0);
  357. return rc;
  358. }
  359. static int
  360. lcs_do_start_thread(struct lcs_card *card, unsigned long thread)
  361. {
  362. unsigned long flags;
  363. int rc = 0;
  364. spin_lock_irqsave(&card->mask_lock, flags);
  365. LCS_DBF_TEXT_(4, trace, " %02x%02x%02x",
  366. (u8) card->thread_start_mask,
  367. (u8) card->thread_allowed_mask,
  368. (u8) card->thread_running_mask);
  369. rc = (card->thread_start_mask & thread);
  370. spin_unlock_irqrestore(&card->mask_lock, flags);
  371. return rc;
  372. }
  373. /**
  374. * Initialize channels,card and state machines.
  375. */
  376. static void
  377. lcs_setup_card(struct lcs_card *card)
  378. {
  379. LCS_DBF_TEXT(2, setup, "initcard");
  380. LCS_DBF_HEX(2, setup, &card, sizeof(void*));
  381. lcs_setup_read(card);
  382. lcs_setup_write(card);
  383. /* Set cards initial state. */
  384. card->state = DEV_STATE_DOWN;
  385. card->tx_buffer = NULL;
  386. card->tx_emitted = 0;
  387. /* Initialize kernel thread task used for LGW commands. */
  388. INIT_WORK(&card->kernel_thread_starter,
  389. (void *)lcs_start_kernel_thread,card);
  390. card->thread_start_mask = 0;
  391. card->thread_allowed_mask = 0;
  392. card->thread_running_mask = 0;
  393. init_waitqueue_head(&card->wait_q);
  394. spin_lock_init(&card->lock);
  395. spin_lock_init(&card->ipm_lock);
  396. spin_lock_init(&card->mask_lock);
  397. #ifdef CONFIG_IP_MULTICAST
  398. INIT_LIST_HEAD(&card->ipm_list);
  399. #endif
  400. INIT_LIST_HEAD(&card->lancmd_waiters);
  401. }
  402. static inline void
  403. lcs_clear_multicast_list(struct lcs_card *card)
  404. {
  405. #ifdef CONFIG_IP_MULTICAST
  406. struct lcs_ipm_list *ipm;
  407. unsigned long flags;
  408. /* Free multicast list. */
  409. LCS_DBF_TEXT(3, setup, "clmclist");
  410. spin_lock_irqsave(&card->ipm_lock, flags);
  411. while (!list_empty(&card->ipm_list)){
  412. ipm = list_entry(card->ipm_list.next,
  413. struct lcs_ipm_list, list);
  414. list_del(&ipm->list);
  415. if (ipm->ipm_state != LCS_IPM_STATE_SET_REQUIRED){
  416. spin_unlock_irqrestore(&card->ipm_lock, flags);
  417. lcs_send_delipm(card, ipm);
  418. spin_lock_irqsave(&card->ipm_lock, flags);
  419. }
  420. kfree(ipm);
  421. }
  422. spin_unlock_irqrestore(&card->ipm_lock, flags);
  423. #endif
  424. }
  425. /**
  426. * Cleanup channels,card and state machines.
  427. */
  428. static void
  429. lcs_cleanup_card(struct lcs_card *card)
  430. {
  431. LCS_DBF_TEXT(3, setup, "cleancrd");
  432. LCS_DBF_HEX(2,setup,&card,sizeof(void*));
  433. if (card->dev != NULL)
  434. free_netdev(card->dev);
  435. /* Cleanup channels. */
  436. lcs_cleanup_channel(&card->write);
  437. lcs_cleanup_channel(&card->read);
  438. }
  439. /**
  440. * Start channel.
  441. */
  442. static int
  443. lcs_start_channel(struct lcs_channel *channel)
  444. {
  445. unsigned long flags;
  446. int rc;
  447. LCS_DBF_TEXT_(4,trace,"ssch%s", channel->ccwdev->dev.bus_id);
  448. spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
  449. rc = ccw_device_start(channel->ccwdev,
  450. channel->ccws + channel->io_idx, 0, 0,
  451. DOIO_DENY_PREFETCH | DOIO_ALLOW_SUSPEND);
  452. if (rc == 0)
  453. channel->state = CH_STATE_RUNNING;
  454. spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
  455. if (rc) {
  456. LCS_DBF_TEXT_(4,trace,"essh%s", channel->ccwdev->dev.bus_id);
  457. PRINT_ERR("Error in starting channel, rc=%d!\n", rc);
  458. }
  459. return rc;
  460. }
  461. static int
  462. lcs_clear_channel(struct lcs_channel *channel)
  463. {
  464. unsigned long flags;
  465. int rc;
  466. LCS_DBF_TEXT(4,trace,"clearch");
  467. LCS_DBF_TEXT_(4,trace,"%s", channel->ccwdev->dev.bus_id);
  468. spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
  469. rc = ccw_device_clear(channel->ccwdev, (addr_t) channel);
  470. spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
  471. if (rc) {
  472. LCS_DBF_TEXT_(4,trace,"ecsc%s", channel->ccwdev->dev.bus_id);
  473. return rc;
  474. }
  475. wait_event(channel->wait_q, (channel->state == CH_STATE_CLEARED));
  476. channel->state = CH_STATE_STOPPED;
  477. return rc;
  478. }
  479. /**
  480. * Stop channel.
  481. */
  482. static int
  483. lcs_stop_channel(struct lcs_channel *channel)
  484. {
  485. unsigned long flags;
  486. int rc;
  487. if (channel->state == CH_STATE_STOPPED)
  488. return 0;
  489. LCS_DBF_TEXT(4,trace,"haltsch");
  490. LCS_DBF_TEXT_(4,trace,"%s", channel->ccwdev->dev.bus_id);
  491. channel->state = CH_STATE_INIT;
  492. spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
  493. rc = ccw_device_halt(channel->ccwdev, (addr_t) channel);
  494. spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
  495. if (rc) {
  496. LCS_DBF_TEXT_(4,trace,"ehsc%s", channel->ccwdev->dev.bus_id);
  497. return rc;
  498. }
  499. /* Asynchronous halt initialted. Wait for its completion. */
  500. wait_event(channel->wait_q, (channel->state == CH_STATE_HALTED));
  501. lcs_clear_channel(channel);
  502. return 0;
  503. }
  504. /**
  505. * start read and write channel
  506. */
  507. static int
  508. lcs_start_channels(struct lcs_card *card)
  509. {
  510. int rc;
  511. LCS_DBF_TEXT(2, trace, "chstart");
  512. /* start read channel */
  513. rc = lcs_start_channel(&card->read);
  514. if (rc)
  515. return rc;
  516. /* start write channel */
  517. rc = lcs_start_channel(&card->write);
  518. if (rc)
  519. lcs_stop_channel(&card->read);
  520. return rc;
  521. }
  522. /**
  523. * stop read and write channel
  524. */
  525. static int
  526. lcs_stop_channels(struct lcs_card *card)
  527. {
  528. LCS_DBF_TEXT(2, trace, "chhalt");
  529. lcs_stop_channel(&card->read);
  530. lcs_stop_channel(&card->write);
  531. return 0;
  532. }
  533. /**
  534. * Get empty buffer.
  535. */
  536. static struct lcs_buffer *
  537. __lcs_get_buffer(struct lcs_channel *channel)
  538. {
  539. int index;
  540. LCS_DBF_TEXT(5, trace, "_getbuff");
  541. index = channel->io_idx;
  542. do {
  543. if (channel->iob[index].state == BUF_STATE_EMPTY) {
  544. channel->iob[index].state = BUF_STATE_LOCKED;
  545. return channel->iob + index;
  546. }
  547. index = (index + 1) & (LCS_NUM_BUFFS - 1);
  548. } while (index != channel->io_idx);
  549. return NULL;
  550. }
  551. static struct lcs_buffer *
  552. lcs_get_buffer(struct lcs_channel *channel)
  553. {
  554. struct lcs_buffer *buffer;
  555. unsigned long flags;
  556. LCS_DBF_TEXT(5, trace, "getbuff");
  557. spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
  558. buffer = __lcs_get_buffer(channel);
  559. spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
  560. return buffer;
  561. }
  562. /**
  563. * Resume channel program if the channel is suspended.
  564. */
  565. static int
  566. __lcs_resume_channel(struct lcs_channel *channel)
  567. {
  568. int rc;
  569. if (channel->state != CH_STATE_SUSPENDED)
  570. return 0;
  571. if (channel->ccws[channel->io_idx].flags & CCW_FLAG_SUSPEND)
  572. return 0;
  573. LCS_DBF_TEXT_(5, trace, "rsch%s", channel->ccwdev->dev.bus_id);
  574. rc = ccw_device_resume(channel->ccwdev);
  575. if (rc) {
  576. LCS_DBF_TEXT_(4, trace, "ersc%s", channel->ccwdev->dev.bus_id);
  577. PRINT_ERR("Error in lcs_resume_channel: rc=%d\n",rc);
  578. } else
  579. channel->state = CH_STATE_RUNNING;
  580. return rc;
  581. }
  582. /**
  583. * Make a buffer ready for processing.
  584. */
  585. static inline void
  586. __lcs_ready_buffer_bits(struct lcs_channel *channel, int index)
  587. {
  588. int prev, next;
  589. LCS_DBF_TEXT(5, trace, "rdybits");
  590. prev = (index - 1) & (LCS_NUM_BUFFS - 1);
  591. next = (index + 1) & (LCS_NUM_BUFFS - 1);
  592. /* Check if we may clear the suspend bit of this buffer. */
  593. if (channel->ccws[next].flags & CCW_FLAG_SUSPEND) {
  594. /* Check if we have to set the PCI bit. */
  595. if (!(channel->ccws[prev].flags & CCW_FLAG_SUSPEND))
  596. /* Suspend bit of the previous buffer is not set. */
  597. channel->ccws[index].flags |= CCW_FLAG_PCI;
  598. /* Suspend bit of the next buffer is set. */
  599. channel->ccws[index].flags &= ~CCW_FLAG_SUSPEND;
  600. }
  601. }
  602. static int
  603. lcs_ready_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
  604. {
  605. unsigned long flags;
  606. int index, rc;
  607. LCS_DBF_TEXT(5, trace, "rdybuff");
  608. if (buffer->state != BUF_STATE_LOCKED &&
  609. buffer->state != BUF_STATE_PROCESSED)
  610. BUG();
  611. spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
  612. buffer->state = BUF_STATE_READY;
  613. index = buffer - channel->iob;
  614. /* Set length. */
  615. channel->ccws[index].count = buffer->count;
  616. /* Check relevant PCI/suspend bits. */
  617. __lcs_ready_buffer_bits(channel, index);
  618. rc = __lcs_resume_channel(channel);
  619. spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
  620. return rc;
  621. }
  622. /**
  623. * Mark the buffer as processed. Take care of the suspend bit
  624. * of the previous buffer. This function is called from
  625. * interrupt context, so the lock must not be taken.
  626. */
  627. static int
  628. __lcs_processed_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
  629. {
  630. int index, prev, next;
  631. LCS_DBF_TEXT(5, trace, "prcsbuff");
  632. if (buffer->state != BUF_STATE_READY)
  633. BUG();
  634. buffer->state = BUF_STATE_PROCESSED;
  635. index = buffer - channel->iob;
  636. prev = (index - 1) & (LCS_NUM_BUFFS - 1);
  637. next = (index + 1) & (LCS_NUM_BUFFS - 1);
  638. /* Set the suspend bit and clear the PCI bit of this buffer. */
  639. channel->ccws[index].flags |= CCW_FLAG_SUSPEND;
  640. channel->ccws[index].flags &= ~CCW_FLAG_PCI;
  641. /* Check the suspend bit of the previous buffer. */
  642. if (channel->iob[prev].state == BUF_STATE_READY) {
  643. /*
  644. * Previous buffer is in state ready. It might have
  645. * happened in lcs_ready_buffer that the suspend bit
  646. * has not been cleared to avoid an endless loop.
  647. * Do it now.
  648. */
  649. __lcs_ready_buffer_bits(channel, prev);
  650. }
  651. /* Clear PCI bit of next buffer. */
  652. channel->ccws[next].flags &= ~CCW_FLAG_PCI;
  653. return __lcs_resume_channel(channel);
  654. }
  655. /**
  656. * Put a processed buffer back to state empty.
  657. */
  658. static void
  659. lcs_release_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
  660. {
  661. unsigned long flags;
  662. LCS_DBF_TEXT(5, trace, "relbuff");
  663. if (buffer->state != BUF_STATE_LOCKED &&
  664. buffer->state != BUF_STATE_PROCESSED)
  665. BUG();
  666. spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
  667. buffer->state = BUF_STATE_EMPTY;
  668. spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
  669. }
  670. /**
  671. * Get buffer for a lan command.
  672. */
  673. static struct lcs_buffer *
  674. lcs_get_lancmd(struct lcs_card *card, int count)
  675. {
  676. struct lcs_buffer *buffer;
  677. struct lcs_cmd *cmd;
  678. LCS_DBF_TEXT(4, trace, "getlncmd");
  679. /* Get buffer and wait if none is available. */
  680. wait_event(card->write.wait_q,
  681. ((buffer = lcs_get_buffer(&card->write)) != NULL));
  682. count += sizeof(struct lcs_header);
  683. *(__u16 *)(buffer->data + count) = 0;
  684. buffer->count = count + sizeof(__u16);
  685. buffer->callback = lcs_release_buffer;
  686. cmd = (struct lcs_cmd *) buffer->data;
  687. cmd->offset = count;
  688. cmd->type = LCS_FRAME_TYPE_CONTROL;
  689. cmd->slot = 0;
  690. return buffer;
  691. }
  692. static void
  693. lcs_get_reply(struct lcs_reply *reply)
  694. {
  695. WARN_ON(atomic_read(&reply->refcnt) <= 0);
  696. atomic_inc(&reply->refcnt);
  697. }
  698. static void
  699. lcs_put_reply(struct lcs_reply *reply)
  700. {
  701. WARN_ON(atomic_read(&reply->refcnt) <= 0);
  702. if (atomic_dec_and_test(&reply->refcnt)) {
  703. kfree(reply);
  704. }
  705. }
  706. static struct lcs_reply *
  707. lcs_alloc_reply(struct lcs_cmd *cmd)
  708. {
  709. struct lcs_reply *reply;
  710. LCS_DBF_TEXT(4, trace, "getreply");
  711. reply = kmalloc(sizeof(struct lcs_reply), GFP_ATOMIC);
  712. if (!reply)
  713. return NULL;
  714. memset(reply,0,sizeof(struct lcs_reply));
  715. atomic_set(&reply->refcnt,1);
  716. reply->sequence_no = cmd->sequence_no;
  717. reply->received = 0;
  718. reply->rc = 0;
  719. init_waitqueue_head(&reply->wait_q);
  720. return reply;
  721. }
  722. /**
  723. * Notifier function for lancmd replies. Called from read irq.
  724. */
  725. static void
  726. lcs_notify_lancmd_waiters(struct lcs_card *card, struct lcs_cmd *cmd)
  727. {
  728. struct list_head *l, *n;
  729. struct lcs_reply *reply;
  730. LCS_DBF_TEXT(4, trace, "notiwait");
  731. spin_lock(&card->lock);
  732. list_for_each_safe(l, n, &card->lancmd_waiters) {
  733. reply = list_entry(l, struct lcs_reply, list);
  734. if (reply->sequence_no == cmd->sequence_no) {
  735. lcs_get_reply(reply);
  736. list_del_init(&reply->list);
  737. if (reply->callback != NULL)
  738. reply->callback(card, cmd);
  739. reply->received = 1;
  740. reply->rc = cmd->return_code;
  741. wake_up(&reply->wait_q);
  742. lcs_put_reply(reply);
  743. break;
  744. }
  745. }
  746. spin_unlock(&card->lock);
  747. }
  748. /**
  749. * Emit buffer of a lan comand.
  750. */
  751. void
  752. lcs_lancmd_timeout(unsigned long data)
  753. {
  754. struct lcs_reply *reply, *list_reply, *r;
  755. unsigned long flags;
  756. LCS_DBF_TEXT(4, trace, "timeout");
  757. reply = (struct lcs_reply *) data;
  758. spin_lock_irqsave(&reply->card->lock, flags);
  759. list_for_each_entry_safe(list_reply, r,
  760. &reply->card->lancmd_waiters,list) {
  761. if (reply == list_reply) {
  762. lcs_get_reply(reply);
  763. list_del_init(&reply->list);
  764. spin_unlock_irqrestore(&reply->card->lock, flags);
  765. reply->received = 1;
  766. reply->rc = -ETIME;
  767. wake_up(&reply->wait_q);
  768. lcs_put_reply(reply);
  769. return;
  770. }
  771. }
  772. spin_unlock_irqrestore(&reply->card->lock, flags);
  773. }
  774. static int
  775. lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer,
  776. void (*reply_callback)(struct lcs_card *, struct lcs_cmd *))
  777. {
  778. struct lcs_reply *reply;
  779. struct lcs_cmd *cmd;
  780. struct timer_list timer;
  781. unsigned long flags;
  782. int rc;
  783. LCS_DBF_TEXT(4, trace, "sendcmd");
  784. cmd = (struct lcs_cmd *) buffer->data;
  785. cmd->return_code = 0;
  786. cmd->sequence_no = card->sequence_no++;
  787. reply = lcs_alloc_reply(cmd);
  788. if (!reply)
  789. return -ENOMEM;
  790. reply->callback = reply_callback;
  791. reply->card = card;
  792. spin_lock_irqsave(&card->lock, flags);
  793. list_add_tail(&reply->list, &card->lancmd_waiters);
  794. spin_unlock_irqrestore(&card->lock, flags);
  795. buffer->callback = lcs_release_buffer;
  796. rc = lcs_ready_buffer(&card->write, buffer);
  797. if (rc)
  798. return rc;
  799. init_timer(&timer);
  800. timer.function = lcs_lancmd_timeout;
  801. timer.data = (unsigned long) reply;
  802. timer.expires = jiffies + HZ*card->lancmd_timeout;
  803. add_timer(&timer);
  804. wait_event(reply->wait_q, reply->received);
  805. del_timer_sync(&timer);
  806. LCS_DBF_TEXT_(4, trace, "rc:%d",reply->rc);
  807. rc = reply->rc;
  808. lcs_put_reply(reply);
  809. return rc ? -EIO : 0;
  810. }
  811. /**
  812. * LCS startup command
  813. */
  814. static int
  815. lcs_send_startup(struct lcs_card *card, __u8 initiator)
  816. {
  817. struct lcs_buffer *buffer;
  818. struct lcs_cmd *cmd;
  819. LCS_DBF_TEXT(2, trace, "startup");
  820. buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
  821. cmd = (struct lcs_cmd *) buffer->data;
  822. cmd->cmd_code = LCS_CMD_STARTUP;
  823. cmd->initiator = initiator;
  824. cmd->cmd.lcs_startup.buff_size = LCS_IOBUFFERSIZE;
  825. return lcs_send_lancmd(card, buffer, NULL);
  826. }
  827. /**
  828. * LCS shutdown command
  829. */
  830. static int
  831. lcs_send_shutdown(struct lcs_card *card)
  832. {
  833. struct lcs_buffer *buffer;
  834. struct lcs_cmd *cmd;
  835. LCS_DBF_TEXT(2, trace, "shutdown");
  836. buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
  837. cmd = (struct lcs_cmd *) buffer->data;
  838. cmd->cmd_code = LCS_CMD_SHUTDOWN;
  839. cmd->initiator = LCS_INITIATOR_TCPIP;
  840. return lcs_send_lancmd(card, buffer, NULL);
  841. }
  842. /**
  843. * LCS lanstat command
  844. */
  845. static void
  846. __lcs_lanstat_cb(struct lcs_card *card, struct lcs_cmd *cmd)
  847. {
  848. LCS_DBF_TEXT(2, trace, "statcb");
  849. memcpy(card->mac, cmd->cmd.lcs_lanstat_cmd.mac_addr, LCS_MAC_LENGTH);
  850. }
  851. static int
  852. lcs_send_lanstat(struct lcs_card *card)
  853. {
  854. struct lcs_buffer *buffer;
  855. struct lcs_cmd *cmd;
  856. LCS_DBF_TEXT(2,trace, "cmdstat");
  857. buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
  858. cmd = (struct lcs_cmd *) buffer->data;
  859. /* Setup lanstat command. */
  860. cmd->cmd_code = LCS_CMD_LANSTAT;
  861. cmd->initiator = LCS_INITIATOR_TCPIP;
  862. cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
  863. cmd->cmd.lcs_std_cmd.portno = card->portno;
  864. return lcs_send_lancmd(card, buffer, __lcs_lanstat_cb);
  865. }
  866. /**
  867. * send stoplan command
  868. */
  869. static int
  870. lcs_send_stoplan(struct lcs_card *card, __u8 initiator)
  871. {
  872. struct lcs_buffer *buffer;
  873. struct lcs_cmd *cmd;
  874. LCS_DBF_TEXT(2, trace, "cmdstpln");
  875. buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
  876. cmd = (struct lcs_cmd *) buffer->data;
  877. cmd->cmd_code = LCS_CMD_STOPLAN;
  878. cmd->initiator = initiator;
  879. cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
  880. cmd->cmd.lcs_std_cmd.portno = card->portno;
  881. return lcs_send_lancmd(card, buffer, NULL);
  882. }
  883. /**
  884. * send startlan command
  885. */
  886. static void
  887. __lcs_send_startlan_cb(struct lcs_card *card, struct lcs_cmd *cmd)
  888. {
  889. LCS_DBF_TEXT(2, trace, "srtlancb");
  890. card->lan_type = cmd->cmd.lcs_std_cmd.lan_type;
  891. card->portno = cmd->cmd.lcs_std_cmd.portno;
  892. }
  893. static int
  894. lcs_send_startlan(struct lcs_card *card, __u8 initiator)
  895. {
  896. struct lcs_buffer *buffer;
  897. struct lcs_cmd *cmd;
  898. LCS_DBF_TEXT(2, trace, "cmdstaln");
  899. buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
  900. cmd = (struct lcs_cmd *) buffer->data;
  901. cmd->cmd_code = LCS_CMD_STARTLAN;
  902. cmd->initiator = initiator;
  903. cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
  904. cmd->cmd.lcs_std_cmd.portno = card->portno;
  905. return lcs_send_lancmd(card, buffer, __lcs_send_startlan_cb);
  906. }
  907. #ifdef CONFIG_IP_MULTICAST
  908. /**
  909. * send setipm command (Multicast)
  910. */
  911. static int
  912. lcs_send_setipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list)
  913. {
  914. struct lcs_buffer *buffer;
  915. struct lcs_cmd *cmd;
  916. LCS_DBF_TEXT(2, trace, "cmdsetim");
  917. buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE);
  918. cmd = (struct lcs_cmd *) buffer->data;
  919. cmd->cmd_code = LCS_CMD_SETIPM;
  920. cmd->initiator = LCS_INITIATOR_TCPIP;
  921. cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
  922. cmd->cmd.lcs_qipassist.portno = card->portno;
  923. cmd->cmd.lcs_qipassist.version = 4;
  924. cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
  925. memcpy(cmd->cmd.lcs_qipassist.lcs_ipass_ctlmsg.ip_mac_pair,
  926. &ipm_list->ipm, sizeof (struct lcs_ip_mac_pair));
  927. LCS_DBF_TEXT_(2, trace, "%x",ipm_list->ipm.ip_addr);
  928. return lcs_send_lancmd(card, buffer, NULL);
  929. }
  930. /**
  931. * send delipm command (Multicast)
  932. */
  933. static int
  934. lcs_send_delipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list)
  935. {
  936. struct lcs_buffer *buffer;
  937. struct lcs_cmd *cmd;
  938. LCS_DBF_TEXT(2, trace, "cmddelim");
  939. buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE);
  940. cmd = (struct lcs_cmd *) buffer->data;
  941. cmd->cmd_code = LCS_CMD_DELIPM;
  942. cmd->initiator = LCS_INITIATOR_TCPIP;
  943. cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
  944. cmd->cmd.lcs_qipassist.portno = card->portno;
  945. cmd->cmd.lcs_qipassist.version = 4;
  946. cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
  947. memcpy(cmd->cmd.lcs_qipassist.lcs_ipass_ctlmsg.ip_mac_pair,
  948. &ipm_list->ipm, sizeof (struct lcs_ip_mac_pair));
  949. LCS_DBF_TEXT_(2, trace, "%x",ipm_list->ipm.ip_addr);
  950. return lcs_send_lancmd(card, buffer, NULL);
  951. }
  952. /**
  953. * check if multicast is supported by LCS
  954. */
  955. static void
  956. __lcs_check_multicast_cb(struct lcs_card *card, struct lcs_cmd *cmd)
  957. {
  958. LCS_DBF_TEXT(2, trace, "chkmccb");
  959. card->ip_assists_supported =
  960. cmd->cmd.lcs_qipassist.ip_assists_supported;
  961. card->ip_assists_enabled =
  962. cmd->cmd.lcs_qipassist.ip_assists_enabled;
  963. }
  964. static int
  965. lcs_check_multicast_support(struct lcs_card *card)
  966. {
  967. struct lcs_buffer *buffer;
  968. struct lcs_cmd *cmd;
  969. int rc;
  970. LCS_DBF_TEXT(2, trace, "cmdqipa");
  971. /* Send query ipassist. */
  972. buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
  973. cmd = (struct lcs_cmd *) buffer->data;
  974. cmd->cmd_code = LCS_CMD_QIPASSIST;
  975. cmd->initiator = LCS_INITIATOR_TCPIP;
  976. cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
  977. cmd->cmd.lcs_qipassist.portno = card->portno;
  978. cmd->cmd.lcs_qipassist.version = 4;
  979. cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
  980. rc = lcs_send_lancmd(card, buffer, __lcs_check_multicast_cb);
  981. if (rc != 0) {
  982. PRINT_ERR("Query IPAssist failed. Assuming unsupported!\n");
  983. return -EOPNOTSUPP;
  984. }
  985. if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT)
  986. return 0;
  987. return -EOPNOTSUPP;
  988. }
  989. /**
  990. * set or del multicast address on LCS card
  991. */
  992. static void
  993. lcs_fix_multicast_list(struct lcs_card *card)
  994. {
  995. struct list_head failed_list;
  996. struct lcs_ipm_list *ipm, *tmp;
  997. unsigned long flags;
  998. int rc;
  999. LCS_DBF_TEXT(4,trace, "fixipm");
  1000. INIT_LIST_HEAD(&failed_list);
  1001. spin_lock_irqsave(&card->ipm_lock, flags);
  1002. list_modified:
  1003. list_for_each_entry_safe(ipm, tmp, &card->ipm_list, list){
  1004. switch (ipm->ipm_state) {
  1005. case LCS_IPM_STATE_SET_REQUIRED:
  1006. /* del from ipm_list so noone else can tamper with
  1007. * this entry */
  1008. list_del_init(&ipm->list);
  1009. spin_unlock_irqrestore(&card->ipm_lock, flags);
  1010. rc = lcs_send_setipm(card, ipm);
  1011. spin_lock_irqsave(&card->ipm_lock, flags);
  1012. if (rc) {
  1013. PRINT_INFO("Adding multicast address failed."
  1014. "Table possibly full!\n");
  1015. /* store ipm in failed list -> will be added
  1016. * to ipm_list again, so a retry will be done
  1017. * during the next call of this function */
  1018. list_add_tail(&ipm->list, &failed_list);
  1019. } else {
  1020. ipm->ipm_state = LCS_IPM_STATE_ON_CARD;
  1021. /* re-insert into ipm_list */
  1022. list_add_tail(&ipm->list, &card->ipm_list);
  1023. }
  1024. goto list_modified;
  1025. case LCS_IPM_STATE_DEL_REQUIRED:
  1026. list_del(&ipm->list);
  1027. spin_unlock_irqrestore(&card->ipm_lock, flags);
  1028. lcs_send_delipm(card, ipm);
  1029. spin_lock_irqsave(&card->ipm_lock, flags);
  1030. kfree(ipm);
  1031. goto list_modified;
  1032. case LCS_IPM_STATE_ON_CARD:
  1033. break;
  1034. }
  1035. }
  1036. /* re-insert all entries from the failed_list into ipm_list */
  1037. list_for_each_entry_safe(ipm, tmp, &failed_list, list) {
  1038. list_del_init(&ipm->list);
  1039. list_add_tail(&ipm->list, &card->ipm_list);
  1040. }
  1041. spin_unlock_irqrestore(&card->ipm_lock, flags);
  1042. if (card->state == DEV_STATE_UP)
  1043. netif_wake_queue(card->dev);
  1044. }
  1045. /**
  1046. * get mac address for the relevant Multicast address
  1047. */
  1048. static void
  1049. lcs_get_mac_for_ipm(__u32 ipm, char *mac, struct net_device *dev)
  1050. {
  1051. LCS_DBF_TEXT(4,trace, "getmac");
  1052. if (dev->type == ARPHRD_IEEE802_TR)
  1053. ip_tr_mc_map(ipm, mac);
  1054. else
  1055. ip_eth_mc_map(ipm, mac);
  1056. }
  1057. /**
  1058. * function called by net device to handle multicast address relevant things
  1059. */
  1060. static inline void
  1061. lcs_remove_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
  1062. {
  1063. struct ip_mc_list *im4;
  1064. struct list_head *l;
  1065. struct lcs_ipm_list *ipm;
  1066. unsigned long flags;
  1067. char buf[MAX_ADDR_LEN];
  1068. LCS_DBF_TEXT(4, trace, "remmclst");
  1069. spin_lock_irqsave(&card->ipm_lock, flags);
  1070. list_for_each(l, &card->ipm_list) {
  1071. ipm = list_entry(l, struct lcs_ipm_list, list);
  1072. for (im4 = in4_dev->mc_list; im4 != NULL; im4 = im4->next) {
  1073. lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
  1074. if ( (ipm->ipm.ip_addr == im4->multiaddr) &&
  1075. (memcmp(buf, &ipm->ipm.mac_addr,
  1076. LCS_MAC_LENGTH) == 0) )
  1077. break;
  1078. }
  1079. if (im4 == NULL)
  1080. ipm->ipm_state = LCS_IPM_STATE_DEL_REQUIRED;
  1081. }
  1082. spin_unlock_irqrestore(&card->ipm_lock, flags);
  1083. }
  1084. static inline struct lcs_ipm_list *
  1085. lcs_check_addr_entry(struct lcs_card *card, struct ip_mc_list *im4, char *buf)
  1086. {
  1087. struct lcs_ipm_list *tmp, *ipm = NULL;
  1088. struct list_head *l;
  1089. unsigned long flags;
  1090. LCS_DBF_TEXT(4, trace, "chkmcent");
  1091. spin_lock_irqsave(&card->ipm_lock, flags);
  1092. list_for_each(l, &card->ipm_list) {
  1093. tmp = list_entry(l, struct lcs_ipm_list, list);
  1094. if ( (tmp->ipm.ip_addr == im4->multiaddr) &&
  1095. (memcmp(buf, &tmp->ipm.mac_addr,
  1096. LCS_MAC_LENGTH) == 0) ) {
  1097. ipm = tmp;
  1098. break;
  1099. }
  1100. }
  1101. spin_unlock_irqrestore(&card->ipm_lock, flags);
  1102. return ipm;
  1103. }
  1104. static inline void
  1105. lcs_set_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
  1106. {
  1107. struct ip_mc_list *im4;
  1108. struct lcs_ipm_list *ipm;
  1109. char buf[MAX_ADDR_LEN];
  1110. unsigned long flags;
  1111. LCS_DBF_TEXT(4, trace, "setmclst");
  1112. for (im4 = in4_dev->mc_list; im4; im4 = im4->next) {
  1113. lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
  1114. ipm = lcs_check_addr_entry(card, im4, buf);
  1115. if (ipm != NULL)
  1116. continue; /* Address already in list. */
  1117. ipm = (struct lcs_ipm_list *)
  1118. kmalloc(sizeof(struct lcs_ipm_list), GFP_ATOMIC);
  1119. if (ipm == NULL) {
  1120. PRINT_INFO("Not enough memory to add "
  1121. "new multicast entry!\n");
  1122. break;
  1123. }
  1124. memset(ipm, 0, sizeof(struct lcs_ipm_list));
  1125. memcpy(&ipm->ipm.mac_addr, buf, LCS_MAC_LENGTH);
  1126. ipm->ipm.ip_addr = im4->multiaddr;
  1127. ipm->ipm_state = LCS_IPM_STATE_SET_REQUIRED;
  1128. spin_lock_irqsave(&card->ipm_lock, flags);
  1129. list_add(&ipm->list, &card->ipm_list);
  1130. spin_unlock_irqrestore(&card->ipm_lock, flags);
  1131. }
  1132. }
  1133. static int
  1134. lcs_register_mc_addresses(void *data)
  1135. {
  1136. struct lcs_card *card;
  1137. struct in_device *in4_dev;
  1138. card = (struct lcs_card *) data;
  1139. daemonize("regipm");
  1140. if (!lcs_do_run_thread(card, LCS_SET_MC_THREAD))
  1141. return 0;
  1142. LCS_DBF_TEXT(4, trace, "regmulti");
  1143. in4_dev = in_dev_get(card->dev);
  1144. if (in4_dev == NULL)
  1145. goto out;
  1146. read_lock(&in4_dev->mc_list_lock);
  1147. lcs_remove_mc_addresses(card,in4_dev);
  1148. lcs_set_mc_addresses(card, in4_dev);
  1149. read_unlock(&in4_dev->mc_list_lock);
  1150. in_dev_put(in4_dev);
  1151. lcs_fix_multicast_list(card);
  1152. out:
  1153. lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD);
  1154. return 0;
  1155. }
  1156. /**
  1157. * function called by net device to
  1158. * handle multicast address relevant things
  1159. */
  1160. static void
  1161. lcs_set_multicast_list(struct net_device *dev)
  1162. {
  1163. struct lcs_card *card;
  1164. LCS_DBF_TEXT(4, trace, "setmulti");
  1165. card = (struct lcs_card *) dev->priv;
  1166. if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD)) {
  1167. schedule_work(&card->kernel_thread_starter);
  1168. }
  1169. }
  1170. #endif /* CONFIG_IP_MULTICAST */
  1171. static long
  1172. lcs_check_irb_error(struct ccw_device *cdev, struct irb *irb)
  1173. {
  1174. if (!IS_ERR(irb))
  1175. return 0;
  1176. switch (PTR_ERR(irb)) {
  1177. case -EIO:
  1178. PRINT_WARN("i/o-error on device %s\n", cdev->dev.bus_id);
  1179. LCS_DBF_TEXT(2, trace, "ckirberr");
  1180. LCS_DBF_TEXT_(2, trace, " rc%d", -EIO);
  1181. break;
  1182. case -ETIMEDOUT:
  1183. PRINT_WARN("timeout on device %s\n", cdev->dev.bus_id);
  1184. LCS_DBF_TEXT(2, trace, "ckirberr");
  1185. LCS_DBF_TEXT_(2, trace, " rc%d", -ETIMEDOUT);
  1186. break;
  1187. default:
  1188. PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb),
  1189. cdev->dev.bus_id);
  1190. LCS_DBF_TEXT(2, trace, "ckirberr");
  1191. LCS_DBF_TEXT(2, trace, " rc???");
  1192. }
  1193. return PTR_ERR(irb);
  1194. }
  1195. /**
  1196. * IRQ Handler for LCS channels
  1197. */
  1198. static void
  1199. lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
  1200. {
  1201. struct lcs_card *card;
  1202. struct lcs_channel *channel;
  1203. int index;
  1204. if (lcs_check_irb_error(cdev, irb))
  1205. return;
  1206. card = CARD_FROM_DEV(cdev);
  1207. if (card->read.ccwdev == cdev)
  1208. channel = &card->read;
  1209. else
  1210. channel = &card->write;
  1211. LCS_DBF_TEXT_(5, trace, "Rint%s",cdev->dev.bus_id);
  1212. LCS_DBF_TEXT_(5, trace, "%4x%4x",irb->scsw.cstat, irb->scsw.dstat);
  1213. LCS_DBF_TEXT_(5, trace, "%4x%4x",irb->scsw.fctl, irb->scsw.actl);
  1214. /* How far in the ccw chain have we processed? */
  1215. if ((channel->state != CH_STATE_INIT) &&
  1216. (irb->scsw.fctl & SCSW_FCTL_START_FUNC)) {
  1217. index = (struct ccw1 *) __va((addr_t) irb->scsw.cpa)
  1218. - channel->ccws;
  1219. if ((irb->scsw.actl & SCSW_ACTL_SUSPENDED) ||
  1220. (irb->scsw.cstat | SCHN_STAT_PCI))
  1221. /* Bloody io subsystem tells us lies about cpa... */
  1222. index = (index - 1) & (LCS_NUM_BUFFS - 1);
  1223. while (channel->io_idx != index) {
  1224. __lcs_processed_buffer(channel,
  1225. channel->iob + channel->io_idx);
  1226. channel->io_idx =
  1227. (channel->io_idx + 1) & (LCS_NUM_BUFFS - 1);
  1228. }
  1229. }
  1230. if ((irb->scsw.dstat & DEV_STAT_DEV_END) ||
  1231. (irb->scsw.dstat & DEV_STAT_CHN_END) ||
  1232. (irb->scsw.dstat & DEV_STAT_UNIT_CHECK))
  1233. /* Mark channel as stopped. */
  1234. channel->state = CH_STATE_STOPPED;
  1235. else if (irb->scsw.actl & SCSW_ACTL_SUSPENDED)
  1236. /* CCW execution stopped on a suspend bit. */
  1237. channel->state = CH_STATE_SUSPENDED;
  1238. if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) {
  1239. if (irb->scsw.cc != 0) {
  1240. ccw_device_halt(channel->ccwdev, (addr_t) channel);
  1241. return;
  1242. }
  1243. /* The channel has been stopped by halt_IO. */
  1244. channel->state = CH_STATE_HALTED;
  1245. }
  1246. if (irb->scsw.fctl & SCSW_FCTL_CLEAR_FUNC) {
  1247. channel->state = CH_STATE_CLEARED;
  1248. }
  1249. /* Do the rest in the tasklet. */
  1250. tasklet_schedule(&channel->irq_tasklet);
  1251. }
  1252. /**
  1253. * Tasklet for IRQ handler
  1254. */
  1255. static void
  1256. lcs_tasklet(unsigned long data)
  1257. {
  1258. unsigned long flags;
  1259. struct lcs_channel *channel;
  1260. struct lcs_buffer *iob;
  1261. int buf_idx;
  1262. int rc;
  1263. channel = (struct lcs_channel *) data;
  1264. LCS_DBF_TEXT_(5, trace, "tlet%s",channel->ccwdev->dev.bus_id);
  1265. /* Check for processed buffers. */
  1266. iob = channel->iob;
  1267. buf_idx = channel->buf_idx;
  1268. while (iob[buf_idx].state == BUF_STATE_PROCESSED) {
  1269. /* Do the callback thing. */
  1270. if (iob[buf_idx].callback != NULL)
  1271. iob[buf_idx].callback(channel, iob + buf_idx);
  1272. buf_idx = (buf_idx + 1) & (LCS_NUM_BUFFS - 1);
  1273. }
  1274. channel->buf_idx = buf_idx;
  1275. if (channel->state == CH_STATE_STOPPED)
  1276. // FIXME: what if rc != 0 ??
  1277. rc = lcs_start_channel(channel);
  1278. spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
  1279. if (channel->state == CH_STATE_SUSPENDED &&
  1280. channel->iob[channel->io_idx].state == BUF_STATE_READY) {
  1281. // FIXME: what if rc != 0 ??
  1282. rc = __lcs_resume_channel(channel);
  1283. }
  1284. spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
  1285. /* Something happened on the channel. Wake up waiters. */
  1286. wake_up(&channel->wait_q);
  1287. }
  1288. /**
  1289. * Finish current tx buffer and make it ready for transmit.
  1290. */
  1291. static void
  1292. __lcs_emit_txbuffer(struct lcs_card *card)
  1293. {
  1294. LCS_DBF_TEXT(5, trace, "emittx");
  1295. *(__u16 *)(card->tx_buffer->data + card->tx_buffer->count) = 0;
  1296. card->tx_buffer->count += 2;
  1297. lcs_ready_buffer(&card->write, card->tx_buffer);
  1298. card->tx_buffer = NULL;
  1299. card->tx_emitted++;
  1300. }
  1301. /**
  1302. * Callback for finished tx buffers.
  1303. */
  1304. static void
  1305. lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
  1306. {
  1307. struct lcs_card *card;
  1308. LCS_DBF_TEXT(5, trace, "txbuffcb");
  1309. /* Put buffer back to pool. */
  1310. lcs_release_buffer(channel, buffer);
  1311. card = (struct lcs_card *)
  1312. ((char *) channel - offsetof(struct lcs_card, write));
  1313. spin_lock(&card->lock);
  1314. card->tx_emitted--;
  1315. if (card->tx_emitted <= 0 && card->tx_buffer != NULL)
  1316. /*
  1317. * Last running tx buffer has finished. Submit partially
  1318. * filled current buffer.
  1319. */
  1320. __lcs_emit_txbuffer(card);
  1321. spin_unlock(&card->lock);
  1322. }
  1323. /**
  1324. * Packet transmit function called by network stack
  1325. */
  1326. static int
  1327. __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb,
  1328. struct net_device *dev)
  1329. {
  1330. struct lcs_header *header;
  1331. LCS_DBF_TEXT(5, trace, "hardxmit");
  1332. if (skb == NULL) {
  1333. card->stats.tx_dropped++;
  1334. card->stats.tx_errors++;
  1335. return -EIO;
  1336. }
  1337. if (card->state != DEV_STATE_UP) {
  1338. dev_kfree_skb(skb);
  1339. card->stats.tx_dropped++;
  1340. card->stats.tx_errors++;
  1341. card->stats.tx_carrier_errors++;
  1342. return 0;
  1343. }
  1344. if (netif_queue_stopped(dev) ) {
  1345. card->stats.tx_dropped++;
  1346. return -EBUSY;
  1347. }
  1348. if (card->tx_buffer != NULL &&
  1349. card->tx_buffer->count + sizeof(struct lcs_header) +
  1350. skb->len + sizeof(u16) > LCS_IOBUFFERSIZE)
  1351. /* skb too big for current tx buffer. */
  1352. __lcs_emit_txbuffer(card);
  1353. if (card->tx_buffer == NULL) {
  1354. /* Get new tx buffer */
  1355. card->tx_buffer = lcs_get_buffer(&card->write);
  1356. if (card->tx_buffer == NULL) {
  1357. card->stats.tx_dropped++;
  1358. return -EBUSY;
  1359. }
  1360. card->tx_buffer->callback = lcs_txbuffer_cb;
  1361. card->tx_buffer->count = 0;
  1362. }
  1363. header = (struct lcs_header *)
  1364. (card->tx_buffer->data + card->tx_buffer->count);
  1365. card->tx_buffer->count += skb->len + sizeof(struct lcs_header);
  1366. header->offset = card->tx_buffer->count;
  1367. header->type = card->lan_type;
  1368. header->slot = card->portno;
  1369. memcpy(header + 1, skb->data, skb->len);
  1370. card->stats.tx_bytes += skb->len;
  1371. card->stats.tx_packets++;
  1372. dev_kfree_skb(skb);
  1373. if (card->tx_emitted <= 0)
  1374. /* If this is the first tx buffer emit it immediately. */
  1375. __lcs_emit_txbuffer(card);
  1376. return 0;
  1377. }
  1378. static int
  1379. lcs_start_xmit(struct sk_buff *skb, struct net_device *dev)
  1380. {
  1381. struct lcs_card *card;
  1382. int rc;
  1383. LCS_DBF_TEXT(5, trace, "pktxmit");
  1384. card = (struct lcs_card *) dev->priv;
  1385. spin_lock(&card->lock);
  1386. rc = __lcs_start_xmit(card, skb, dev);
  1387. spin_unlock(&card->lock);
  1388. return rc;
  1389. }
  1390. /**
  1391. * send startlan and lanstat command to make LCS device ready
  1392. */
  1393. static int
  1394. lcs_startlan_auto(struct lcs_card *card)
  1395. {
  1396. int rc;
  1397. LCS_DBF_TEXT(2, trace, "strtauto");
  1398. #ifdef CONFIG_NET_ETHERNET
  1399. card->lan_type = LCS_FRAME_TYPE_ENET;
  1400. rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
  1401. if (rc == 0)
  1402. return 0;
  1403. #endif
  1404. #ifdef CONFIG_TR
  1405. card->lan_type = LCS_FRAME_TYPE_TR;
  1406. rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
  1407. if (rc == 0)
  1408. return 0;
  1409. #endif
  1410. #ifdef CONFIG_FDDI
  1411. card->lan_type = LCS_FRAME_TYPE_FDDI;
  1412. rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
  1413. if (rc == 0)
  1414. return 0;
  1415. #endif
  1416. return -EIO;
  1417. }
  1418. static int
  1419. lcs_startlan(struct lcs_card *card)
  1420. {
  1421. int rc, i;
  1422. LCS_DBF_TEXT(2, trace, "startlan");
  1423. rc = 0;
  1424. if (card->portno != LCS_INVALID_PORT_NO) {
  1425. if (card->lan_type == LCS_FRAME_TYPE_AUTO)
  1426. rc = lcs_startlan_auto(card);
  1427. else
  1428. rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
  1429. } else {
  1430. for (i = 0; i <= 16; i++) {
  1431. card->portno = i;
  1432. if (card->lan_type != LCS_FRAME_TYPE_AUTO)
  1433. rc = lcs_send_startlan(card,
  1434. LCS_INITIATOR_TCPIP);
  1435. else
  1436. /* autodetecting lan type */
  1437. rc = lcs_startlan_auto(card);
  1438. if (rc == 0)
  1439. break;
  1440. }
  1441. }
  1442. if (rc == 0)
  1443. return lcs_send_lanstat(card);
  1444. return rc;
  1445. }
  1446. /**
  1447. * LCS detect function
  1448. * setup channels and make them I/O ready
  1449. */
  1450. static int
  1451. lcs_detect(struct lcs_card *card)
  1452. {
  1453. int rc = 0;
  1454. LCS_DBF_TEXT(2, setup, "lcsdetct");
  1455. /* start/reset card */
  1456. if (card->dev)
  1457. netif_stop_queue(card->dev);
  1458. rc = lcs_stop_channels(card);
  1459. if (rc == 0) {
  1460. rc = lcs_start_channels(card);
  1461. if (rc == 0) {
  1462. rc = lcs_send_startup(card, LCS_INITIATOR_TCPIP);
  1463. if (rc == 0)
  1464. rc = lcs_startlan(card);
  1465. }
  1466. }
  1467. if (rc == 0) {
  1468. card->state = DEV_STATE_UP;
  1469. } else {
  1470. card->state = DEV_STATE_DOWN;
  1471. card->write.state = CH_STATE_INIT;
  1472. card->read.state = CH_STATE_INIT;
  1473. }
  1474. return rc;
  1475. }
  1476. /**
  1477. * reset card
  1478. */
  1479. static int
  1480. lcs_resetcard(struct lcs_card *card)
  1481. {
  1482. int retries;
  1483. LCS_DBF_TEXT(2, trace, "rescard");
  1484. for (retries = 0; retries < 10; retries++) {
  1485. if (lcs_detect(card) == 0) {
  1486. netif_wake_queue(card->dev);
  1487. card->state = DEV_STATE_UP;
  1488. PRINT_INFO("LCS device %s successfully restarted!\n",
  1489. card->dev->name);
  1490. return 0;
  1491. }
  1492. msleep(3000);
  1493. }
  1494. PRINT_ERR("Error in Reseting LCS card!\n");
  1495. return -EIO;
  1496. }
  1497. /**
  1498. * LCS Stop card
  1499. */
  1500. static int
  1501. lcs_stopcard(struct lcs_card *card)
  1502. {
  1503. int rc;
  1504. LCS_DBF_TEXT(3, setup, "stopcard");
  1505. if (card->read.state != CH_STATE_STOPPED &&
  1506. card->write.state != CH_STATE_STOPPED &&
  1507. card->state == DEV_STATE_UP) {
  1508. lcs_clear_multicast_list(card);
  1509. rc = lcs_send_stoplan(card,LCS_INITIATOR_TCPIP);
  1510. rc = lcs_send_shutdown(card);
  1511. }
  1512. rc = lcs_stop_channels(card);
  1513. card->state = DEV_STATE_DOWN;
  1514. return rc;
  1515. }
  1516. /**
  1517. * LGW initiated commands
  1518. */
  1519. static int
  1520. lcs_lgw_startlan_thread(void *data)
  1521. {
  1522. struct lcs_card *card;
  1523. card = (struct lcs_card *) data;
  1524. daemonize("lgwstpln");
  1525. if (!lcs_do_run_thread(card, LCS_STARTLAN_THREAD))
  1526. return 0;
  1527. LCS_DBF_TEXT(4, trace, "lgwstpln");
  1528. if (card->dev)
  1529. netif_stop_queue(card->dev);
  1530. if (lcs_startlan(card) == 0) {
  1531. netif_wake_queue(card->dev);
  1532. card->state = DEV_STATE_UP;
  1533. PRINT_INFO("LCS Startlan for device %s succeeded!\n",
  1534. card->dev->name);
  1535. } else
  1536. PRINT_ERR("LCS Startlan for device %s failed!\n",
  1537. card->dev->name);
  1538. lcs_clear_thread_running_bit(card, LCS_STARTLAN_THREAD);
  1539. return 0;
  1540. }
  1541. /**
  1542. * Send startup command initiated by Lan Gateway
  1543. */
  1544. static int
  1545. lcs_lgw_startup_thread(void *data)
  1546. {
  1547. int rc;
  1548. struct lcs_card *card;
  1549. card = (struct lcs_card *) data;
  1550. daemonize("lgwstaln");
  1551. if (!lcs_do_run_thread(card, LCS_STARTUP_THREAD))
  1552. return 0;
  1553. LCS_DBF_TEXT(4, trace, "lgwstaln");
  1554. if (card->dev)
  1555. netif_stop_queue(card->dev);
  1556. rc = lcs_send_startup(card, LCS_INITIATOR_LGW);
  1557. if (rc != 0) {
  1558. PRINT_ERR("Startup for LCS device %s initiated " \
  1559. "by LGW failed!\nReseting card ...\n",
  1560. card->dev->name);
  1561. /* do a card reset */
  1562. rc = lcs_resetcard(card);
  1563. if (rc == 0)
  1564. goto Done;
  1565. }
  1566. rc = lcs_startlan(card);
  1567. if (rc == 0) {
  1568. netif_wake_queue(card->dev);
  1569. card->state = DEV_STATE_UP;
  1570. }
  1571. Done:
  1572. if (rc == 0)
  1573. PRINT_INFO("LCS Startup for device %s succeeded!\n",
  1574. card->dev->name);
  1575. else
  1576. PRINT_ERR("LCS Startup for device %s failed!\n",
  1577. card->dev->name);
  1578. lcs_clear_thread_running_bit(card, LCS_STARTUP_THREAD);
  1579. return 0;
  1580. }
  1581. /**
  1582. * send stoplan command initiated by Lan Gateway
  1583. */
  1584. static int
  1585. lcs_lgw_stoplan_thread(void *data)
  1586. {
  1587. struct lcs_card *card;
  1588. int rc;
  1589. card = (struct lcs_card *) data;
  1590. daemonize("lgwstop");
  1591. if (!lcs_do_run_thread(card, LCS_STOPLAN_THREAD))
  1592. return 0;
  1593. LCS_DBF_TEXT(4, trace, "lgwstop");
  1594. if (card->dev)
  1595. netif_stop_queue(card->dev);
  1596. if (lcs_send_stoplan(card, LCS_INITIATOR_LGW) == 0)
  1597. PRINT_INFO("Stoplan for %s initiated by LGW succeeded!\n",
  1598. card->dev->name);
  1599. else
  1600. PRINT_ERR("Stoplan %s initiated by LGW failed!\n",
  1601. card->dev->name);
  1602. /*Try to reset the card, stop it on failure */
  1603. rc = lcs_resetcard(card);
  1604. if (rc != 0)
  1605. rc = lcs_stopcard(card);
  1606. lcs_clear_thread_running_bit(card, LCS_STOPLAN_THREAD);
  1607. return rc;
  1608. }
  1609. /**
  1610. * Kernel Thread helper functions for LGW initiated commands
  1611. */
  1612. static void
  1613. lcs_start_kernel_thread(struct lcs_card *card)
  1614. {
  1615. LCS_DBF_TEXT(5, trace, "krnthrd");
  1616. if (lcs_do_start_thread(card, LCS_STARTUP_THREAD))
  1617. kernel_thread(lcs_lgw_startup_thread, (void *) card, SIGCHLD);
  1618. if (lcs_do_start_thread(card, LCS_STARTLAN_THREAD))
  1619. kernel_thread(lcs_lgw_startlan_thread, (void *) card, SIGCHLD);
  1620. if (lcs_do_start_thread(card, LCS_STOPLAN_THREAD))
  1621. kernel_thread(lcs_lgw_stoplan_thread, (void *) card, SIGCHLD);
  1622. #ifdef CONFIG_IP_MULTICAST
  1623. if (lcs_do_start_thread(card, LCS_SET_MC_THREAD))
  1624. kernel_thread(lcs_register_mc_addresses, (void *) card, SIGCHLD);
  1625. #endif
  1626. }
  1627. /**
  1628. * Process control frames.
  1629. */
  1630. static void
  1631. lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd)
  1632. {
  1633. LCS_DBF_TEXT(5, trace, "getctrl");
  1634. if (cmd->initiator == LCS_INITIATOR_LGW) {
  1635. switch(cmd->cmd_code) {
  1636. case LCS_CMD_STARTUP:
  1637. if (!lcs_set_thread_start_bit(card,
  1638. LCS_STARTUP_THREAD))
  1639. schedule_work(&card->kernel_thread_starter);
  1640. break;
  1641. case LCS_CMD_STARTLAN:
  1642. if (!lcs_set_thread_start_bit(card,
  1643. LCS_STARTLAN_THREAD))
  1644. schedule_work(&card->kernel_thread_starter);
  1645. break;
  1646. case LCS_CMD_STOPLAN:
  1647. if (!lcs_set_thread_start_bit(card,
  1648. LCS_STOPLAN_THREAD))
  1649. schedule_work(&card->kernel_thread_starter);
  1650. break;
  1651. default:
  1652. PRINT_INFO("UNRECOGNIZED LGW COMMAND\n");
  1653. break;
  1654. }
  1655. } else
  1656. lcs_notify_lancmd_waiters(card, cmd);
  1657. }
  1658. /**
  1659. * Unpack network packet.
  1660. */
  1661. static void
  1662. lcs_get_skb(struct lcs_card *card, char *skb_data, unsigned int skb_len)
  1663. {
  1664. struct sk_buff *skb;
  1665. LCS_DBF_TEXT(5, trace, "getskb");
  1666. if (card->dev == NULL ||
  1667. card->state != DEV_STATE_UP)
  1668. /* The card isn't up. Ignore the packet. */
  1669. return;
  1670. skb = dev_alloc_skb(skb_len);
  1671. if (skb == NULL) {
  1672. PRINT_ERR("LCS: alloc_skb failed for device=%s\n",
  1673. card->dev->name);
  1674. card->stats.rx_dropped++;
  1675. return;
  1676. }
  1677. skb->dev = card->dev;
  1678. memcpy(skb_put(skb, skb_len), skb_data, skb_len);
  1679. skb->protocol = card->lan_type_trans(skb, card->dev);
  1680. card->stats.rx_bytes += skb_len;
  1681. card->stats.rx_packets++;
  1682. *((__u32 *)skb->cb) = ++card->pkt_seq;
  1683. netif_rx(skb);
  1684. }
  1685. /**
  1686. * LCS main routine to get packets and lancmd replies from the buffers
  1687. */
  1688. static void
  1689. lcs_get_frames_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
  1690. {
  1691. struct lcs_card *card;
  1692. struct lcs_header *lcs_hdr;
  1693. __u16 offset;
  1694. LCS_DBF_TEXT(5, trace, "lcsgtpkt");
  1695. lcs_hdr = (struct lcs_header *) buffer->data;
  1696. if (lcs_hdr->offset == LCS_ILLEGAL_OFFSET) {
  1697. LCS_DBF_TEXT(4, trace, "-eiogpkt");
  1698. return;
  1699. }
  1700. card = (struct lcs_card *)
  1701. ((char *) channel - offsetof(struct lcs_card, read));
  1702. offset = 0;
  1703. while (lcs_hdr->offset != 0) {
  1704. if (lcs_hdr->offset <= 0 ||
  1705. lcs_hdr->offset > LCS_IOBUFFERSIZE ||
  1706. lcs_hdr->offset < offset) {
  1707. /* Offset invalid. */
  1708. card->stats.rx_length_errors++;
  1709. card->stats.rx_errors++;
  1710. return;
  1711. }
  1712. /* What kind of frame is it? */
  1713. if (lcs_hdr->type == LCS_FRAME_TYPE_CONTROL)
  1714. /* Control frame. */
  1715. lcs_get_control(card, (struct lcs_cmd *) lcs_hdr);
  1716. else if (lcs_hdr->type == LCS_FRAME_TYPE_ENET ||
  1717. lcs_hdr->type == LCS_FRAME_TYPE_TR ||
  1718. lcs_hdr->type == LCS_FRAME_TYPE_FDDI)
  1719. /* Normal network packet. */
  1720. lcs_get_skb(card, (char *)(lcs_hdr + 1),
  1721. lcs_hdr->offset - offset -
  1722. sizeof(struct lcs_header));
  1723. else
  1724. /* Unknown frame type. */
  1725. ; // FIXME: error message ?
  1726. /* Proceed to next frame. */
  1727. offset = lcs_hdr->offset;
  1728. lcs_hdr->offset = LCS_ILLEGAL_OFFSET;
  1729. lcs_hdr = (struct lcs_header *) (buffer->data + offset);
  1730. }
  1731. /* The buffer is now empty. Make it ready again. */
  1732. lcs_ready_buffer(&card->read, buffer);
  1733. }
  1734. /**
  1735. * get network statistics for ifconfig and other user programs
  1736. */
  1737. static struct net_device_stats *
  1738. lcs_getstats(struct net_device *dev)
  1739. {
  1740. struct lcs_card *card;
  1741. LCS_DBF_TEXT(4, trace, "netstats");
  1742. card = (struct lcs_card *) dev->priv;
  1743. return &card->stats;
  1744. }
  1745. /**
  1746. * stop lcs device
  1747. * This function will be called by user doing ifconfig xxx down
  1748. */
  1749. static int
  1750. lcs_stop_device(struct net_device *dev)
  1751. {
  1752. struct lcs_card *card;
  1753. int rc;
  1754. LCS_DBF_TEXT(2, trace, "stopdev");
  1755. card = (struct lcs_card *) dev->priv;
  1756. netif_stop_queue(dev);
  1757. dev->flags &= ~IFF_UP;
  1758. rc = lcs_stopcard(card);
  1759. if (rc)
  1760. PRINT_ERR("Try it again!\n ");
  1761. return rc;
  1762. }
  1763. /**
  1764. * start lcs device and make it runnable
  1765. * This function will be called by user doing ifconfig xxx up
  1766. */
  1767. static int
  1768. lcs_open_device(struct net_device *dev)
  1769. {
  1770. struct lcs_card *card;
  1771. int rc;
  1772. LCS_DBF_TEXT(2, trace, "opendev");
  1773. card = (struct lcs_card *) dev->priv;
  1774. /* initialize statistics */
  1775. rc = lcs_detect(card);
  1776. if (rc) {
  1777. PRINT_ERR("LCS:Error in opening device!\n");
  1778. } else {
  1779. dev->flags |= IFF_UP;
  1780. netif_wake_queue(dev);
  1781. card->state = DEV_STATE_UP;
  1782. }
  1783. return rc;
  1784. }
  1785. /**
  1786. * show function for portno called by cat or similar things
  1787. */
  1788. static ssize_t
  1789. lcs_portno_show (struct device *dev, struct device_attribute *attr, char *buf)
  1790. {
  1791. struct lcs_card *card;
  1792. card = (struct lcs_card *)dev->driver_data;
  1793. if (!card)
  1794. return 0;
  1795. return sprintf(buf, "%d\n", card->portno);
  1796. }
  1797. /**
  1798. * store the value which is piped to file portno
  1799. */
  1800. static ssize_t
  1801. lcs_portno_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
  1802. {
  1803. struct lcs_card *card;
  1804. int value;
  1805. card = (struct lcs_card *)dev->driver_data;
  1806. if (!card)
  1807. return 0;
  1808. sscanf(buf, "%u", &value);
  1809. /* TODO: sanity checks */
  1810. card->portno = value;
  1811. return count;
  1812. }
  1813. static DEVICE_ATTR(portno, 0644, lcs_portno_show, lcs_portno_store);
  1814. static ssize_t
  1815. lcs_type_show(struct device *dev, struct device_attribute *attr, char *buf)
  1816. {
  1817. struct ccwgroup_device *cgdev;
  1818. cgdev = to_ccwgroupdev(dev);
  1819. if (!cgdev)
  1820. return -ENODEV;
  1821. return sprintf(buf, "%s\n", cu3088_type[cgdev->cdev[0]->id.driver_info]);
  1822. }
  1823. static DEVICE_ATTR(type, 0444, lcs_type_show, NULL);
  1824. static ssize_t
  1825. lcs_timeout_show(struct device *dev, struct device_attribute *attr, char *buf)
  1826. {
  1827. struct lcs_card *card;
  1828. card = (struct lcs_card *)dev->driver_data;
  1829. return card ? sprintf(buf, "%u\n", card->lancmd_timeout) : 0;
  1830. }
  1831. static ssize_t
  1832. lcs_timeout_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
  1833. {
  1834. struct lcs_card *card;
  1835. int value;
  1836. card = (struct lcs_card *)dev->driver_data;
  1837. if (!card)
  1838. return 0;
  1839. sscanf(buf, "%u", &value);
  1840. /* TODO: sanity checks */
  1841. card->lancmd_timeout = value;
  1842. return count;
  1843. }
  1844. DEVICE_ATTR(lancmd_timeout, 0644, lcs_timeout_show, lcs_timeout_store);
  1845. static struct attribute * lcs_attrs[] = {
  1846. &dev_attr_portno.attr,
  1847. &dev_attr_type.attr,
  1848. &dev_attr_lancmd_timeout.attr,
  1849. NULL,
  1850. };
  1851. static struct attribute_group lcs_attr_group = {
  1852. .attrs = lcs_attrs,
  1853. };
  1854. /**
  1855. * lcs_probe_device is called on establishing a new ccwgroup_device.
  1856. */
  1857. static int
  1858. lcs_probe_device(struct ccwgroup_device *ccwgdev)
  1859. {
  1860. struct lcs_card *card;
  1861. int ret;
  1862. if (!get_device(&ccwgdev->dev))
  1863. return -ENODEV;
  1864. LCS_DBF_TEXT(2, setup, "add_dev");
  1865. card = lcs_alloc_card();
  1866. if (!card) {
  1867. PRINT_ERR("Allocation of lcs card failed\n");
  1868. put_device(&ccwgdev->dev);
  1869. return -ENOMEM;
  1870. }
  1871. ret = sysfs_create_group(&ccwgdev->dev.kobj, &lcs_attr_group);
  1872. if (ret) {
  1873. PRINT_ERR("Creating attributes failed");
  1874. lcs_free_card(card);
  1875. put_device(&ccwgdev->dev);
  1876. return ret;
  1877. }
  1878. ccwgdev->dev.driver_data = card;
  1879. ccwgdev->cdev[0]->handler = lcs_irq;
  1880. ccwgdev->cdev[1]->handler = lcs_irq;
  1881. return 0;
  1882. }
  1883. static int
  1884. lcs_register_netdev(struct ccwgroup_device *ccwgdev)
  1885. {
  1886. struct lcs_card *card;
  1887. LCS_DBF_TEXT(2, setup, "regnetdv");
  1888. card = (struct lcs_card *)ccwgdev->dev.driver_data;
  1889. if (card->dev->reg_state != NETREG_UNINITIALIZED)
  1890. return 0;
  1891. SET_NETDEV_DEV(card->dev, &ccwgdev->dev);
  1892. return register_netdev(card->dev);
  1893. }
  1894. /**
  1895. * lcs_new_device will be called by setting the group device online.
  1896. */
  1897. static int
  1898. lcs_new_device(struct ccwgroup_device *ccwgdev)
  1899. {
  1900. struct lcs_card *card;
  1901. struct net_device *dev=NULL;
  1902. enum lcs_dev_states recover_state;
  1903. int rc;
  1904. card = (struct lcs_card *)ccwgdev->dev.driver_data;
  1905. if (!card)
  1906. return -ENODEV;
  1907. LCS_DBF_TEXT(2, setup, "newdev");
  1908. LCS_DBF_HEX(3, setup, &card, sizeof(void*));
  1909. card->read.ccwdev = ccwgdev->cdev[0];
  1910. card->write.ccwdev = ccwgdev->cdev[1];
  1911. recover_state = card->state;
  1912. ccw_device_set_online(card->read.ccwdev);
  1913. ccw_device_set_online(card->write.ccwdev);
  1914. LCS_DBF_TEXT(3, setup, "lcsnewdv");
  1915. lcs_setup_card(card);
  1916. rc = lcs_detect(card);
  1917. if (rc) {
  1918. LCS_DBF_TEXT(2, setup, "dtctfail");
  1919. PRINT_WARN("Detection of LCS card failed with return code "
  1920. "%d (0x%x)\n", rc, rc);
  1921. lcs_stopcard(card);
  1922. goto out;
  1923. }
  1924. if (card->dev) {
  1925. LCS_DBF_TEXT(2, setup, "samedev");
  1926. LCS_DBF_HEX(3, setup, &card, sizeof(void*));
  1927. goto netdev_out;
  1928. }
  1929. switch (card->lan_type) {
  1930. #ifdef CONFIG_NET_ETHERNET
  1931. case LCS_FRAME_TYPE_ENET:
  1932. card->lan_type_trans = eth_type_trans;
  1933. dev = alloc_etherdev(0);
  1934. break;
  1935. #endif
  1936. #ifdef CONFIG_TR
  1937. case LCS_FRAME_TYPE_TR:
  1938. card->lan_type_trans = tr_type_trans;
  1939. dev = alloc_trdev(0);
  1940. break;
  1941. #endif
  1942. #ifdef CONFIG_FDDI
  1943. case LCS_FRAME_TYPE_FDDI:
  1944. card->lan_type_trans = fddi_type_trans;
  1945. dev = alloc_fddidev(0);
  1946. break;
  1947. #endif
  1948. default:
  1949. LCS_DBF_TEXT(3, setup, "errinit");
  1950. PRINT_ERR("LCS: Initialization failed\n");
  1951. PRINT_ERR("LCS: No device found!\n");
  1952. goto out;
  1953. }
  1954. if (!dev)
  1955. goto out;
  1956. card->dev = dev;
  1957. card->dev->priv = card;
  1958. card->dev->open = lcs_open_device;
  1959. card->dev->stop = lcs_stop_device;
  1960. card->dev->hard_start_xmit = lcs_start_xmit;
  1961. card->dev->get_stats = lcs_getstats;
  1962. SET_MODULE_OWNER(dev);
  1963. memcpy(card->dev->dev_addr, card->mac, LCS_MAC_LENGTH);
  1964. #ifdef CONFIG_IP_MULTICAST
  1965. if (!lcs_check_multicast_support(card))
  1966. card->dev->set_multicast_list = lcs_set_multicast_list;
  1967. #endif
  1968. netdev_out:
  1969. lcs_set_allowed_threads(card,0xffffffff);
  1970. if (recover_state == DEV_STATE_RECOVER) {
  1971. lcs_set_multicast_list(card->dev);
  1972. card->dev->flags |= IFF_UP;
  1973. netif_wake_queue(card->dev);
  1974. card->state = DEV_STATE_UP;
  1975. } else {
  1976. lcs_stopcard(card);
  1977. }
  1978. if (lcs_register_netdev(ccwgdev) != 0)
  1979. goto out;
  1980. /* Print out supported assists: IPv6 */
  1981. PRINT_INFO("LCS device %s %s IPv6 support\n", card->dev->name,
  1982. (card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ?
  1983. "with" : "without");
  1984. /* Print out supported assist: Multicast */
  1985. PRINT_INFO("LCS device %s %s Multicast support\n", card->dev->name,
  1986. (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ?
  1987. "with" : "without");
  1988. return 0;
  1989. out:
  1990. ccw_device_set_offline(card->read.ccwdev);
  1991. ccw_device_set_offline(card->write.ccwdev);
  1992. return -ENODEV;
  1993. }
  1994. /**
  1995. * lcs_shutdown_device, called when setting the group device offline.
  1996. */
  1997. static int
  1998. lcs_shutdown_device(struct ccwgroup_device *ccwgdev)
  1999. {
  2000. struct lcs_card *card;
  2001. enum lcs_dev_states recover_state;
  2002. int ret;
  2003. LCS_DBF_TEXT(3, setup, "shtdndev");
  2004. card = (struct lcs_card *)ccwgdev->dev.driver_data;
  2005. if (!card)
  2006. return -ENODEV;
  2007. lcs_set_allowed_threads(card, 0);
  2008. if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD))
  2009. return -ERESTARTSYS;
  2010. LCS_DBF_HEX(3, setup, &card, sizeof(void*));
  2011. recover_state = card->state;
  2012. ret = lcs_stop_device(card->dev);
  2013. ret = ccw_device_set_offline(card->read.ccwdev);
  2014. ret = ccw_device_set_offline(card->write.ccwdev);
  2015. if (recover_state == DEV_STATE_UP) {
  2016. card->state = DEV_STATE_RECOVER;
  2017. }
  2018. if (ret)
  2019. return ret;
  2020. return 0;
  2021. }
  2022. /**
  2023. * lcs_remove_device, free buffers and card
  2024. */
  2025. static void
  2026. lcs_remove_device(struct ccwgroup_device *ccwgdev)
  2027. {
  2028. struct lcs_card *card;
  2029. card = (struct lcs_card *)ccwgdev->dev.driver_data;
  2030. if (!card)
  2031. return;
  2032. PRINT_INFO("Removing lcs group device ....\n");
  2033. LCS_DBF_TEXT(3, setup, "remdev");
  2034. LCS_DBF_HEX(3, setup, &card, sizeof(void*));
  2035. if (ccwgdev->state == CCWGROUP_ONLINE) {
  2036. lcs_shutdown_device(ccwgdev);
  2037. }
  2038. if (card->dev)
  2039. unregister_netdev(card->dev);
  2040. sysfs_remove_group(&ccwgdev->dev.kobj, &lcs_attr_group);
  2041. lcs_cleanup_card(card);
  2042. lcs_free_card(card);
  2043. put_device(&ccwgdev->dev);
  2044. }
  2045. /**
  2046. * LCS ccwgroup driver registration
  2047. */
  2048. static struct ccwgroup_driver lcs_group_driver = {
  2049. .owner = THIS_MODULE,
  2050. .name = "lcs",
  2051. .max_slaves = 2,
  2052. .driver_id = 0xD3C3E2,
  2053. .probe = lcs_probe_device,
  2054. .remove = lcs_remove_device,
  2055. .set_online = lcs_new_device,
  2056. .set_offline = lcs_shutdown_device,
  2057. };
  2058. /**
  2059. * LCS Module/Kernel initialization function
  2060. */
  2061. static int
  2062. __init lcs_init_module(void)
  2063. {
  2064. int rc;
  2065. PRINT_INFO("Loading %s\n",version);
  2066. rc = lcs_register_debug_facility();
  2067. LCS_DBF_TEXT(0, setup, "lcsinit");
  2068. if (rc) {
  2069. PRINT_ERR("Initialization failed\n");
  2070. return rc;
  2071. }
  2072. rc = register_cu3088_discipline(&lcs_group_driver);
  2073. if (rc) {
  2074. PRINT_ERR("Initialization failed\n");
  2075. return rc;
  2076. }
  2077. return 0;
  2078. }
  2079. /**
  2080. * LCS module cleanup function
  2081. */
  2082. static void
  2083. __exit lcs_cleanup_module(void)
  2084. {
  2085. PRINT_INFO("Terminating lcs module.\n");
  2086. LCS_DBF_TEXT(0, trace, "cleanup");
  2087. unregister_cu3088_discipline(&lcs_group_driver);
  2088. lcs_unregister_debug_facility();
  2089. }
  2090. module_init(lcs_init_module);
  2091. module_exit(lcs_cleanup_module);
  2092. MODULE_AUTHOR("Frank Pavlic <fpavlic@de.ibm.com>");
  2093. MODULE_LICENSE("GPL");