caif_hsi.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. /*
  2. * Copyright (C) ST-Ericsson AB 2010
  3. * Contact: Sjur Brendeland / sjur.brandeland@stericsson.com
  4. * Author: Daniel Martensson / daniel.martensson@stericsson.com
  5. * Dmitry.Tarnyagin / dmitry.tarnyagin@stericsson.com
  6. * License terms: GNU General Public License (GPL) version 2.
  7. */
  8. #include <linux/init.h>
  9. #include <linux/module.h>
  10. #include <linux/device.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/netdevice.h>
  13. #include <linux/string.h>
  14. #include <linux/list.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/delay.h>
  17. #include <linux/sched.h>
  18. #include <linux/if_arp.h>
  19. #include <linux/timer.h>
  20. #include <net/caif/caif_layer.h>
  21. #include <net/caif/caif_hsi.h>
  22. MODULE_LICENSE("GPL");
  23. MODULE_AUTHOR("Daniel Martensson<daniel.martensson@stericsson.com>");
  24. MODULE_DESCRIPTION("CAIF HSI driver");
  25. /* Returns the number of padding bytes for alignment. */
  26. #define PAD_POW2(x, pow) ((((x)&((pow)-1)) == 0) ? 0 :\
  27. (((pow)-((x)&((pow)-1)))))
  28. /*
  29. * HSI padding options.
  30. * Warning: must be a base of 2 (& operation used) and can not be zero !
  31. */
  32. static int hsi_head_align = 4;
  33. module_param(hsi_head_align, int, S_IRUGO);
  34. MODULE_PARM_DESC(hsi_head_align, "HSI head alignment.");
  35. static int hsi_tail_align = 4;
  36. module_param(hsi_tail_align, int, S_IRUGO);
  37. MODULE_PARM_DESC(hsi_tail_align, "HSI tail alignment.");
  38. /*
  39. * HSI link layer flowcontrol thresholds.
  40. * Warning: A high threshold value migth increase throughput but it will at
  41. * the same time prevent channel prioritization and increase the risk of
  42. * flooding the modem. The high threshold should be above the low.
  43. */
  44. static int hsi_high_threshold = 100;
  45. module_param(hsi_high_threshold, int, S_IRUGO);
  46. MODULE_PARM_DESC(hsi_high_threshold, "HSI high threshold (FLOW OFF).");
  47. static int hsi_low_threshold = 50;
  48. module_param(hsi_low_threshold, int, S_IRUGO);
  49. MODULE_PARM_DESC(hsi_low_threshold, "HSI high threshold (FLOW ON).");
  50. #define ON 1
  51. #define OFF 0
  52. /*
  53. * Threshold values for the HSI packet queue. Flowcontrol will be asserted
  54. * when the number of packets exceeds HIGH_WATER_MARK. It will not be
  55. * de-asserted before the number of packets drops below LOW_WATER_MARK.
  56. */
  57. #define LOW_WATER_MARK hsi_low_threshold
  58. #define HIGH_WATER_MARK hsi_high_threshold
  59. static LIST_HEAD(cfhsi_list);
  60. static spinlock_t cfhsi_list_lock;
  61. static void cfhsi_inactivity_tout(unsigned long arg)
  62. {
  63. struct cfhsi *cfhsi = (struct cfhsi *)arg;
  64. dev_dbg(&cfhsi->ndev->dev, "%s.\n",
  65. __func__);
  66. /* Schedule power down work queue. */
  67. if (!test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))
  68. queue_work(cfhsi->wq, &cfhsi->wake_down_work);
  69. }
  70. static void cfhsi_abort_tx(struct cfhsi *cfhsi)
  71. {
  72. struct sk_buff *skb;
  73. for (;;) {
  74. spin_lock_bh(&cfhsi->lock);
  75. skb = skb_dequeue(&cfhsi->qhead);
  76. if (!skb)
  77. break;
  78. cfhsi->ndev->stats.tx_errors++;
  79. cfhsi->ndev->stats.tx_dropped++;
  80. spin_unlock_bh(&cfhsi->lock);
  81. kfree_skb(skb);
  82. }
  83. cfhsi->tx_state = CFHSI_TX_STATE_IDLE;
  84. if (!test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))
  85. mod_timer(&cfhsi->timer, jiffies + CFHSI_INACTIVITY_TOUT);
  86. spin_unlock_bh(&cfhsi->lock);
  87. }
  88. static int cfhsi_flush_fifo(struct cfhsi *cfhsi)
  89. {
  90. char buffer[32]; /* Any reasonable value */
  91. size_t fifo_occupancy;
  92. int ret;
  93. dev_dbg(&cfhsi->ndev->dev, "%s.\n",
  94. __func__);
  95. ret = cfhsi->dev->cfhsi_wake_up(cfhsi->dev);
  96. if (ret) {
  97. dev_warn(&cfhsi->ndev->dev,
  98. "%s: can't wake up HSI interface: %d.\n",
  99. __func__, ret);
  100. return ret;
  101. }
  102. do {
  103. ret = cfhsi->dev->cfhsi_fifo_occupancy(cfhsi->dev,
  104. &fifo_occupancy);
  105. if (ret) {
  106. dev_warn(&cfhsi->ndev->dev,
  107. "%s: can't get FIFO occupancy: %d.\n",
  108. __func__, ret);
  109. break;
  110. } else if (!fifo_occupancy)
  111. /* No more data, exitting normally */
  112. break;
  113. fifo_occupancy = min(sizeof(buffer), fifo_occupancy);
  114. set_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits);
  115. ret = cfhsi->dev->cfhsi_rx(buffer, fifo_occupancy,
  116. cfhsi->dev);
  117. if (ret) {
  118. clear_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits);
  119. dev_warn(&cfhsi->ndev->dev,
  120. "%s: can't read data: %d.\n",
  121. __func__, ret);
  122. break;
  123. }
  124. ret = 5 * HZ;
  125. ret = wait_event_interruptible_timeout(cfhsi->flush_fifo_wait,
  126. !test_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits), ret);
  127. if (ret < 0) {
  128. dev_warn(&cfhsi->ndev->dev,
  129. "%s: can't wait for flush complete: %d.\n",
  130. __func__, ret);
  131. break;
  132. } else if (!ret) {
  133. ret = -ETIMEDOUT;
  134. dev_warn(&cfhsi->ndev->dev,
  135. "%s: timeout waiting for flush complete.\n",
  136. __func__);
  137. break;
  138. }
  139. } while (1);
  140. cfhsi->dev->cfhsi_wake_down(cfhsi->dev);
  141. return ret;
  142. }
  143. static int cfhsi_tx_frm(struct cfhsi_desc *desc, struct cfhsi *cfhsi)
  144. {
  145. int nfrms = 0;
  146. int pld_len = 0;
  147. struct sk_buff *skb;
  148. u8 *pfrm = desc->emb_frm + CFHSI_MAX_EMB_FRM_SZ;
  149. skb = skb_dequeue(&cfhsi->qhead);
  150. if (!skb)
  151. return 0;
  152. /* Clear offset. */
  153. desc->offset = 0;
  154. /* Check if we can embed a CAIF frame. */
  155. if (skb->len < CFHSI_MAX_EMB_FRM_SZ) {
  156. struct caif_payload_info *info;
  157. int hpad = 0;
  158. int tpad = 0;
  159. /* Calculate needed head alignment and tail alignment. */
  160. info = (struct caif_payload_info *)&skb->cb;
  161. hpad = 1 + PAD_POW2((info->hdr_len + 1), hsi_head_align);
  162. tpad = PAD_POW2((skb->len + hpad), hsi_tail_align);
  163. /* Check if frame still fits with added alignment. */
  164. if ((skb->len + hpad + tpad) <= CFHSI_MAX_EMB_FRM_SZ) {
  165. u8 *pemb = desc->emb_frm;
  166. desc->offset = CFHSI_DESC_SHORT_SZ;
  167. *pemb = (u8)(hpad - 1);
  168. pemb += hpad;
  169. /* Update network statistics. */
  170. cfhsi->ndev->stats.tx_packets++;
  171. cfhsi->ndev->stats.tx_bytes += skb->len;
  172. /* Copy in embedded CAIF frame. */
  173. skb_copy_bits(skb, 0, pemb, skb->len);
  174. consume_skb(skb);
  175. skb = NULL;
  176. }
  177. }
  178. /* Create payload CAIF frames. */
  179. pfrm = desc->emb_frm + CFHSI_MAX_EMB_FRM_SZ;
  180. while (nfrms < CFHSI_MAX_PKTS) {
  181. struct caif_payload_info *info;
  182. int hpad = 0;
  183. int tpad = 0;
  184. if (!skb)
  185. skb = skb_dequeue(&cfhsi->qhead);
  186. if (!skb)
  187. break;
  188. /* Calculate needed head alignment and tail alignment. */
  189. info = (struct caif_payload_info *)&skb->cb;
  190. hpad = 1 + PAD_POW2((info->hdr_len + 1), hsi_head_align);
  191. tpad = PAD_POW2((skb->len + hpad), hsi_tail_align);
  192. /* Fill in CAIF frame length in descriptor. */
  193. desc->cffrm_len[nfrms] = hpad + skb->len + tpad;
  194. /* Fill head padding information. */
  195. *pfrm = (u8)(hpad - 1);
  196. pfrm += hpad;
  197. /* Update network statistics. */
  198. cfhsi->ndev->stats.tx_packets++;
  199. cfhsi->ndev->stats.tx_bytes += skb->len;
  200. /* Copy in CAIF frame. */
  201. skb_copy_bits(skb, 0, pfrm, skb->len);
  202. /* Update payload length. */
  203. pld_len += desc->cffrm_len[nfrms];
  204. /* Update frame pointer. */
  205. pfrm += skb->len + tpad;
  206. consume_skb(skb);
  207. skb = NULL;
  208. /* Update number of frames. */
  209. nfrms++;
  210. }
  211. /* Unused length fields should be zero-filled (according to SPEC). */
  212. while (nfrms < CFHSI_MAX_PKTS) {
  213. desc->cffrm_len[nfrms] = 0x0000;
  214. nfrms++;
  215. }
  216. /* Check if we can piggy-back another descriptor. */
  217. skb = skb_peek(&cfhsi->qhead);
  218. if (skb)
  219. desc->header |= CFHSI_PIGGY_DESC;
  220. else
  221. desc->header &= ~CFHSI_PIGGY_DESC;
  222. return CFHSI_DESC_SZ + pld_len;
  223. }
  224. static void cfhsi_tx_done(struct cfhsi *cfhsi)
  225. {
  226. struct cfhsi_desc *desc = NULL;
  227. int len = 0;
  228. int res;
  229. dev_dbg(&cfhsi->ndev->dev, "%s.\n", __func__);
  230. if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))
  231. return;
  232. desc = (struct cfhsi_desc *)cfhsi->tx_buf;
  233. do {
  234. /*
  235. * Send flow on if flow off has been previously signalled
  236. * and number of packets is below low water mark.
  237. */
  238. spin_lock_bh(&cfhsi->lock);
  239. if (cfhsi->flow_off_sent &&
  240. cfhsi->qhead.qlen <= cfhsi->q_low_mark &&
  241. cfhsi->cfdev.flowctrl) {
  242. cfhsi->flow_off_sent = 0;
  243. cfhsi->cfdev.flowctrl(cfhsi->ndev, ON);
  244. }
  245. spin_unlock_bh(&cfhsi->lock);
  246. /* Create HSI frame. */
  247. do {
  248. len = cfhsi_tx_frm(desc, cfhsi);
  249. if (!len) {
  250. spin_lock_bh(&cfhsi->lock);
  251. if (unlikely(skb_peek(&cfhsi->qhead))) {
  252. spin_unlock_bh(&cfhsi->lock);
  253. continue;
  254. }
  255. cfhsi->tx_state = CFHSI_TX_STATE_IDLE;
  256. /* Start inactivity timer. */
  257. mod_timer(&cfhsi->timer,
  258. jiffies + CFHSI_INACTIVITY_TOUT);
  259. spin_unlock_bh(&cfhsi->lock);
  260. goto done;
  261. }
  262. } while (!len);
  263. /* Set up new transfer. */
  264. res = cfhsi->dev->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->dev);
  265. if (WARN_ON(res < 0)) {
  266. dev_err(&cfhsi->ndev->dev, "%s: TX error %d.\n",
  267. __func__, res);
  268. }
  269. } while (res < 0);
  270. done:
  271. return;
  272. }
  273. static void cfhsi_tx_done_cb(struct cfhsi_drv *drv)
  274. {
  275. struct cfhsi *cfhsi;
  276. cfhsi = container_of(drv, struct cfhsi, drv);
  277. dev_dbg(&cfhsi->ndev->dev, "%s.\n",
  278. __func__);
  279. if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))
  280. return;
  281. cfhsi_tx_done(cfhsi);
  282. }
  283. static int cfhsi_rx_desc(struct cfhsi_desc *desc, struct cfhsi *cfhsi,
  284. bool *dump)
  285. {
  286. int xfer_sz = 0;
  287. int nfrms = 0;
  288. u16 *plen = NULL;
  289. u8 *pfrm = NULL;
  290. if ((desc->header & ~CFHSI_PIGGY_DESC) ||
  291. (desc->offset > CFHSI_MAX_EMB_FRM_SZ)) {
  292. dev_err(&cfhsi->ndev->dev, "%s: Invalid descriptor.\n",
  293. __func__);
  294. *dump = true;
  295. return 0;
  296. }
  297. /* Check for embedded CAIF frame. */
  298. if (desc->offset) {
  299. struct sk_buff *skb;
  300. u8 *dst = NULL;
  301. int len = 0;
  302. pfrm = ((u8 *)desc) + desc->offset;
  303. /* Remove offset padding. */
  304. pfrm += *pfrm + 1;
  305. /* Read length of CAIF frame (little endian). */
  306. len = *pfrm;
  307. len |= ((*(pfrm+1)) << 8) & 0xFF00;
  308. len += 2; /* Add FCS fields. */
  309. /* Allocate SKB (OK even in IRQ context). */
  310. skb = alloc_skb(len + 1, GFP_ATOMIC);
  311. if (!skb) {
  312. dev_err(&cfhsi->ndev->dev, "%s: Out of memory !\n",
  313. __func__);
  314. return -ENOMEM;
  315. }
  316. caif_assert(skb != NULL);
  317. dst = skb_put(skb, len);
  318. memcpy(dst, pfrm, len);
  319. skb->protocol = htons(ETH_P_CAIF);
  320. skb_reset_mac_header(skb);
  321. skb->dev = cfhsi->ndev;
  322. /*
  323. * We are called from a arch specific platform device.
  324. * Unfortunately we don't know what context we're
  325. * running in.
  326. */
  327. if (in_interrupt())
  328. netif_rx(skb);
  329. else
  330. netif_rx_ni(skb);
  331. /* Update network statistics. */
  332. cfhsi->ndev->stats.rx_packets++;
  333. cfhsi->ndev->stats.rx_bytes += len;
  334. }
  335. /* Calculate transfer length. */
  336. plen = desc->cffrm_len;
  337. while (nfrms < CFHSI_MAX_PKTS && *plen) {
  338. xfer_sz += *plen;
  339. plen++;
  340. nfrms++;
  341. }
  342. /* Check for piggy-backed descriptor. */
  343. if (desc->header & CFHSI_PIGGY_DESC)
  344. xfer_sz += CFHSI_DESC_SZ;
  345. if (xfer_sz % 4) {
  346. dev_err(&cfhsi->ndev->dev,
  347. "%s: Invalid payload len: %d, ignored.\n",
  348. __func__, xfer_sz);
  349. xfer_sz = 0;
  350. *dump = true;
  351. }
  352. return xfer_sz;
  353. }
  354. static int cfhsi_rx_pld(struct cfhsi_desc *desc, struct cfhsi *cfhsi,
  355. bool *dump)
  356. {
  357. int rx_sz = 0;
  358. int nfrms = 0;
  359. u16 *plen = NULL;
  360. u8 *pfrm = NULL;
  361. /* Sanity check header and offset. */
  362. if (WARN_ON((desc->header & ~CFHSI_PIGGY_DESC) ||
  363. (desc->offset > CFHSI_MAX_EMB_FRM_SZ))) {
  364. dev_err(&cfhsi->ndev->dev, "%s: Invalid descriptor.\n",
  365. __func__);
  366. *dump = true;
  367. return -EINVAL;
  368. }
  369. /* Set frame pointer to start of payload. */
  370. pfrm = desc->emb_frm + CFHSI_MAX_EMB_FRM_SZ;
  371. plen = desc->cffrm_len;
  372. /* Skip already processed frames. */
  373. while (nfrms < cfhsi->rx_state.nfrms) {
  374. pfrm += *plen;
  375. rx_sz += *plen;
  376. plen++;
  377. nfrms++;
  378. }
  379. /* Parse payload. */
  380. while (nfrms < CFHSI_MAX_PKTS && *plen) {
  381. struct sk_buff *skb;
  382. u8 *dst = NULL;
  383. u8 *pcffrm = NULL;
  384. int len = 0;
  385. if (WARN_ON(desc->cffrm_len[nfrms] > CFHSI_MAX_PAYLOAD_SZ)) {
  386. dev_err(&cfhsi->ndev->dev, "%s: Invalid payload.\n",
  387. __func__);
  388. *dump = true;
  389. return -EINVAL;
  390. }
  391. /* CAIF frame starts after head padding. */
  392. pcffrm = pfrm + *pfrm + 1;
  393. /* Read length of CAIF frame (little endian). */
  394. len = *pcffrm;
  395. len |= ((*(pcffrm + 1)) << 8) & 0xFF00;
  396. len += 2; /* Add FCS fields. */
  397. /* Allocate SKB (OK even in IRQ context). */
  398. skb = alloc_skb(len + 1, GFP_ATOMIC);
  399. if (!skb) {
  400. dev_err(&cfhsi->ndev->dev, "%s: Out of memory !\n",
  401. __func__);
  402. cfhsi->rx_state.nfrms = nfrms;
  403. return -ENOMEM;
  404. }
  405. caif_assert(skb != NULL);
  406. dst = skb_put(skb, len);
  407. memcpy(dst, pcffrm, len);
  408. skb->protocol = htons(ETH_P_CAIF);
  409. skb_reset_mac_header(skb);
  410. skb->dev = cfhsi->ndev;
  411. /*
  412. * We're called from a platform device,
  413. * and don't know the context we're running in.
  414. */
  415. if (in_interrupt())
  416. netif_rx(skb);
  417. else
  418. netif_rx_ni(skb);
  419. /* Update network statistics. */
  420. cfhsi->ndev->stats.rx_packets++;
  421. cfhsi->ndev->stats.rx_bytes += len;
  422. pfrm += *plen;
  423. rx_sz += *plen;
  424. plen++;
  425. nfrms++;
  426. }
  427. return rx_sz;
  428. }
  429. static void cfhsi_rx_done(struct cfhsi *cfhsi)
  430. {
  431. int res;
  432. int desc_pld_len = 0;
  433. struct cfhsi_desc *desc = NULL;
  434. bool dump = false;
  435. desc = (struct cfhsi_desc *)cfhsi->rx_buf;
  436. dev_dbg(&cfhsi->ndev->dev, "%s\n", __func__);
  437. if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))
  438. return;
  439. /* Update inactivity timer if pending. */
  440. spin_lock_bh(&cfhsi->lock);
  441. mod_timer_pending(&cfhsi->timer, jiffies + CFHSI_INACTIVITY_TOUT);
  442. spin_unlock_bh(&cfhsi->lock);
  443. if (cfhsi->rx_state.state == CFHSI_RX_STATE_DESC) {
  444. desc_pld_len = cfhsi_rx_desc(desc, cfhsi, &dump);
  445. if (desc_pld_len == -ENOMEM)
  446. goto restart;
  447. } else {
  448. int pld_len;
  449. if (!cfhsi->rx_state.piggy_desc) {
  450. pld_len = cfhsi_rx_pld(desc, cfhsi, &dump);
  451. if (pld_len == -ENOMEM)
  452. goto restart;
  453. cfhsi->rx_state.pld_len = pld_len;
  454. } else {
  455. pld_len = cfhsi->rx_state.pld_len;
  456. }
  457. if ((pld_len > 0) && (desc->header & CFHSI_PIGGY_DESC)) {
  458. struct cfhsi_desc *piggy_desc;
  459. piggy_desc = (struct cfhsi_desc *)
  460. (desc->emb_frm + CFHSI_MAX_EMB_FRM_SZ +
  461. pld_len);
  462. cfhsi->rx_state.piggy_desc = true;
  463. /* Extract piggy-backed descriptor. */
  464. desc_pld_len = cfhsi_rx_desc(piggy_desc, cfhsi, &dump);
  465. if (desc_pld_len == -ENOMEM)
  466. goto restart;
  467. /*
  468. * Copy needed information from the piggy-backed
  469. * descriptor to the descriptor in the start.
  470. */
  471. memcpy((u8 *)desc, (u8 *)piggy_desc,
  472. CFHSI_DESC_SHORT_SZ);
  473. }
  474. }
  475. if (unlikely(dump)) {
  476. size_t rx_offset = cfhsi->rx_ptr - cfhsi->rx_buf;
  477. dev_err(&cfhsi->ndev->dev, "%s: RX offset: %u.\n",
  478. __func__, (unsigned) rx_offset);
  479. print_hex_dump_bytes("--> ", DUMP_PREFIX_NONE,
  480. cfhsi->rx_buf, cfhsi->rx_len + rx_offset);
  481. }
  482. memset(&cfhsi->rx_state, 0, sizeof(cfhsi->rx_state));
  483. if (desc_pld_len) {
  484. cfhsi->rx_state.state = CFHSI_RX_STATE_PAYLOAD;
  485. cfhsi->rx_ptr = cfhsi->rx_buf + CFHSI_DESC_SZ;
  486. cfhsi->rx_len = desc_pld_len;
  487. } else {
  488. cfhsi->rx_state.state = CFHSI_RX_STATE_DESC;
  489. cfhsi->rx_ptr = cfhsi->rx_buf;
  490. cfhsi->rx_len = CFHSI_DESC_SZ;
  491. }
  492. if (test_bit(CFHSI_AWAKE, &cfhsi->bits)) {
  493. /* Set up new transfer. */
  494. dev_dbg(&cfhsi->ndev->dev, "%s: Start RX.\n",
  495. __func__);
  496. res = cfhsi->dev->cfhsi_rx(cfhsi->rx_ptr, cfhsi->rx_len,
  497. cfhsi->dev);
  498. if (WARN_ON(res < 0)) {
  499. dev_err(&cfhsi->ndev->dev, "%s: RX error %d.\n",
  500. __func__, res);
  501. cfhsi->ndev->stats.rx_errors++;
  502. cfhsi->ndev->stats.rx_dropped++;
  503. }
  504. }
  505. return;
  506. restart:
  507. if (++cfhsi->rx_state.retries > CFHSI_MAX_RX_RETRIES) {
  508. dev_err(&cfhsi->ndev->dev, "%s: No memory available "
  509. "in %d iterations.\n",
  510. __func__, CFHSI_MAX_RX_RETRIES);
  511. BUG();
  512. }
  513. mod_timer(&cfhsi->rx_slowpath_timer, jiffies + 1);
  514. }
  515. static void cfhsi_rx_slowpath(unsigned long arg)
  516. {
  517. struct cfhsi *cfhsi = (struct cfhsi *)arg;
  518. dev_dbg(&cfhsi->ndev->dev, "%s.\n",
  519. __func__);
  520. cfhsi_rx_done(cfhsi);
  521. }
  522. static void cfhsi_rx_done_cb(struct cfhsi_drv *drv)
  523. {
  524. struct cfhsi *cfhsi;
  525. cfhsi = container_of(drv, struct cfhsi, drv);
  526. dev_dbg(&cfhsi->ndev->dev, "%s.\n",
  527. __func__);
  528. if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))
  529. return;
  530. if (test_and_clear_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits))
  531. wake_up_interruptible(&cfhsi->flush_fifo_wait);
  532. else
  533. cfhsi_rx_done(cfhsi);
  534. }
  535. static void cfhsi_wake_up(struct work_struct *work)
  536. {
  537. struct cfhsi *cfhsi = NULL;
  538. int res;
  539. int len;
  540. long ret;
  541. cfhsi = container_of(work, struct cfhsi, wake_up_work);
  542. if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))
  543. return;
  544. if (unlikely(test_bit(CFHSI_AWAKE, &cfhsi->bits))) {
  545. /* It happenes when wakeup is requested by
  546. * both ends at the same time. */
  547. clear_bit(CFHSI_WAKE_UP, &cfhsi->bits);
  548. return;
  549. }
  550. /* Activate wake line. */
  551. cfhsi->dev->cfhsi_wake_up(cfhsi->dev);
  552. dev_dbg(&cfhsi->ndev->dev, "%s: Start waiting.\n",
  553. __func__);
  554. /* Wait for acknowledge. */
  555. ret = CFHSI_WAKE_TOUT;
  556. ret = wait_event_interruptible_timeout(cfhsi->wake_up_wait,
  557. test_and_clear_bit(CFHSI_WAKE_UP_ACK,
  558. &cfhsi->bits), ret);
  559. if (unlikely(ret < 0)) {
  560. /* Interrupted by signal. */
  561. dev_info(&cfhsi->ndev->dev, "%s: Signalled: %ld.\n",
  562. __func__, ret);
  563. clear_bit(CFHSI_WAKE_UP, &cfhsi->bits);
  564. cfhsi->dev->cfhsi_wake_down(cfhsi->dev);
  565. return;
  566. } else if (!ret) {
  567. /* Wakeup timeout */
  568. dev_err(&cfhsi->ndev->dev, "%s: Timeout.\n",
  569. __func__);
  570. clear_bit(CFHSI_WAKE_UP, &cfhsi->bits);
  571. cfhsi->dev->cfhsi_wake_down(cfhsi->dev);
  572. return;
  573. }
  574. dev_dbg(&cfhsi->ndev->dev, "%s: Woken.\n",
  575. __func__);
  576. /* Clear power up bit. */
  577. set_bit(CFHSI_AWAKE, &cfhsi->bits);
  578. clear_bit(CFHSI_WAKE_UP, &cfhsi->bits);
  579. /* Resume read operation. */
  580. dev_dbg(&cfhsi->ndev->dev, "%s: Start RX.\n", __func__);
  581. res = cfhsi->dev->cfhsi_rx(cfhsi->rx_ptr, cfhsi->rx_len, cfhsi->dev);
  582. if (WARN_ON(res < 0))
  583. dev_err(&cfhsi->ndev->dev, "%s: RX err %d.\n", __func__, res);
  584. /* Clear power up acknowledment. */
  585. clear_bit(CFHSI_WAKE_UP_ACK, &cfhsi->bits);
  586. spin_lock_bh(&cfhsi->lock);
  587. /* Resume transmit if queue is not empty. */
  588. if (!skb_peek(&cfhsi->qhead)) {
  589. dev_dbg(&cfhsi->ndev->dev, "%s: Peer wake, start timer.\n",
  590. __func__);
  591. /* Start inactivity timer. */
  592. mod_timer(&cfhsi->timer,
  593. jiffies + CFHSI_INACTIVITY_TOUT);
  594. spin_unlock_bh(&cfhsi->lock);
  595. return;
  596. }
  597. dev_dbg(&cfhsi->ndev->dev, "%s: Host wake.\n",
  598. __func__);
  599. spin_unlock_bh(&cfhsi->lock);
  600. /* Create HSI frame. */
  601. len = cfhsi_tx_frm((struct cfhsi_desc *)cfhsi->tx_buf, cfhsi);
  602. if (likely(len > 0)) {
  603. /* Set up new transfer. */
  604. res = cfhsi->dev->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->dev);
  605. if (WARN_ON(res < 0)) {
  606. dev_err(&cfhsi->ndev->dev, "%s: TX error %d.\n",
  607. __func__, res);
  608. cfhsi_abort_tx(cfhsi);
  609. }
  610. } else {
  611. dev_err(&cfhsi->ndev->dev,
  612. "%s: Failed to create HSI frame: %d.\n",
  613. __func__, len);
  614. }
  615. }
  616. static void cfhsi_wake_down(struct work_struct *work)
  617. {
  618. long ret;
  619. struct cfhsi *cfhsi = NULL;
  620. size_t fifo_occupancy = 0;
  621. int retry = CFHSI_WAKE_TOUT;
  622. cfhsi = container_of(work, struct cfhsi, wake_down_work);
  623. dev_dbg(&cfhsi->ndev->dev, "%s.\n", __func__);
  624. if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))
  625. return;
  626. /* Deactivate wake line. */
  627. cfhsi->dev->cfhsi_wake_down(cfhsi->dev);
  628. /* Wait for acknowledge. */
  629. ret = CFHSI_WAKE_TOUT;
  630. ret = wait_event_interruptible_timeout(cfhsi->wake_down_wait,
  631. test_and_clear_bit(CFHSI_WAKE_DOWN_ACK,
  632. &cfhsi->bits), ret);
  633. if (ret < 0) {
  634. /* Interrupted by signal. */
  635. dev_info(&cfhsi->ndev->dev, "%s: Signalled: %ld.\n",
  636. __func__, ret);
  637. return;
  638. } else if (!ret) {
  639. /* Timeout */
  640. dev_err(&cfhsi->ndev->dev, "%s: Timeout.\n", __func__);
  641. }
  642. /* Check FIFO occupancy. */
  643. while (retry) {
  644. WARN_ON(cfhsi->dev->cfhsi_fifo_occupancy(cfhsi->dev,
  645. &fifo_occupancy));
  646. if (!fifo_occupancy)
  647. break;
  648. set_current_state(TASK_INTERRUPTIBLE);
  649. schedule_timeout(1);
  650. retry--;
  651. }
  652. if (!retry)
  653. dev_err(&cfhsi->ndev->dev, "%s: FIFO Timeout.\n", __func__);
  654. /* Clear AWAKE condition. */
  655. clear_bit(CFHSI_AWAKE, &cfhsi->bits);
  656. /* Cancel pending RX requests. */
  657. cfhsi->dev->cfhsi_rx_cancel(cfhsi->dev);
  658. }
  659. static void cfhsi_wake_up_cb(struct cfhsi_drv *drv)
  660. {
  661. struct cfhsi *cfhsi = NULL;
  662. cfhsi = container_of(drv, struct cfhsi, drv);
  663. dev_dbg(&cfhsi->ndev->dev, "%s.\n",
  664. __func__);
  665. set_bit(CFHSI_WAKE_UP_ACK, &cfhsi->bits);
  666. wake_up_interruptible(&cfhsi->wake_up_wait);
  667. if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))
  668. return;
  669. /* Schedule wake up work queue if the peer initiates. */
  670. if (!test_and_set_bit(CFHSI_WAKE_UP, &cfhsi->bits))
  671. queue_work(cfhsi->wq, &cfhsi->wake_up_work);
  672. }
  673. static void cfhsi_wake_down_cb(struct cfhsi_drv *drv)
  674. {
  675. struct cfhsi *cfhsi = NULL;
  676. cfhsi = container_of(drv, struct cfhsi, drv);
  677. dev_dbg(&cfhsi->ndev->dev, "%s.\n",
  678. __func__);
  679. /* Initiating low power is only permitted by the host (us). */
  680. set_bit(CFHSI_WAKE_DOWN_ACK, &cfhsi->bits);
  681. wake_up_interruptible(&cfhsi->wake_down_wait);
  682. }
  683. static int cfhsi_xmit(struct sk_buff *skb, struct net_device *dev)
  684. {
  685. struct cfhsi *cfhsi = NULL;
  686. int start_xfer = 0;
  687. int timer_active;
  688. if (!dev)
  689. return -EINVAL;
  690. cfhsi = netdev_priv(dev);
  691. spin_lock_bh(&cfhsi->lock);
  692. skb_queue_tail(&cfhsi->qhead, skb);
  693. /* Sanity check; xmit should not be called after unregister_netdev */
  694. if (WARN_ON(test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))) {
  695. spin_unlock_bh(&cfhsi->lock);
  696. cfhsi_abort_tx(cfhsi);
  697. return -EINVAL;
  698. }
  699. /* Send flow off if number of packets is above high water mark. */
  700. if (!cfhsi->flow_off_sent &&
  701. cfhsi->qhead.qlen > cfhsi->q_high_mark &&
  702. cfhsi->cfdev.flowctrl) {
  703. cfhsi->flow_off_sent = 1;
  704. cfhsi->cfdev.flowctrl(cfhsi->ndev, OFF);
  705. }
  706. if (cfhsi->tx_state == CFHSI_TX_STATE_IDLE) {
  707. cfhsi->tx_state = CFHSI_TX_STATE_XFER;
  708. start_xfer = 1;
  709. }
  710. if (!start_xfer) {
  711. spin_unlock_bh(&cfhsi->lock);
  712. return 0;
  713. }
  714. /* Delete inactivity timer if started. */
  715. timer_active = del_timer_sync(&cfhsi->timer);
  716. spin_unlock_bh(&cfhsi->lock);
  717. if (timer_active) {
  718. struct cfhsi_desc *desc = (struct cfhsi_desc *)cfhsi->tx_buf;
  719. int len;
  720. int res;
  721. /* Create HSI frame. */
  722. len = cfhsi_tx_frm(desc, cfhsi);
  723. BUG_ON(!len);
  724. /* Set up new transfer. */
  725. res = cfhsi->dev->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->dev);
  726. if (WARN_ON(res < 0)) {
  727. dev_err(&cfhsi->ndev->dev, "%s: TX error %d.\n",
  728. __func__, res);
  729. cfhsi_abort_tx(cfhsi);
  730. }
  731. } else {
  732. /* Schedule wake up work queue if the we initiate. */
  733. if (!test_and_set_bit(CFHSI_WAKE_UP, &cfhsi->bits))
  734. queue_work(cfhsi->wq, &cfhsi->wake_up_work);
  735. }
  736. return 0;
  737. }
  738. static int cfhsi_open(struct net_device *dev)
  739. {
  740. netif_wake_queue(dev);
  741. return 0;
  742. }
  743. static int cfhsi_close(struct net_device *dev)
  744. {
  745. netif_stop_queue(dev);
  746. return 0;
  747. }
  748. static const struct net_device_ops cfhsi_ops = {
  749. .ndo_open = cfhsi_open,
  750. .ndo_stop = cfhsi_close,
  751. .ndo_start_xmit = cfhsi_xmit
  752. };
  753. static void cfhsi_setup(struct net_device *dev)
  754. {
  755. struct cfhsi *cfhsi = netdev_priv(dev);
  756. dev->features = 0;
  757. dev->netdev_ops = &cfhsi_ops;
  758. dev->type = ARPHRD_CAIF;
  759. dev->flags = IFF_POINTOPOINT | IFF_NOARP;
  760. dev->mtu = CFHSI_MAX_PAYLOAD_SZ;
  761. dev->tx_queue_len = 0;
  762. dev->destructor = free_netdev;
  763. skb_queue_head_init(&cfhsi->qhead);
  764. cfhsi->cfdev.link_select = CAIF_LINK_HIGH_BANDW;
  765. cfhsi->cfdev.use_frag = false;
  766. cfhsi->cfdev.use_stx = false;
  767. cfhsi->cfdev.use_fcs = false;
  768. cfhsi->ndev = dev;
  769. }
  770. int cfhsi_probe(struct platform_device *pdev)
  771. {
  772. struct cfhsi *cfhsi = NULL;
  773. struct net_device *ndev;
  774. struct cfhsi_dev *dev;
  775. int res;
  776. ndev = alloc_netdev(sizeof(struct cfhsi), "cfhsi%d", cfhsi_setup);
  777. if (!ndev)
  778. return -ENODEV;
  779. cfhsi = netdev_priv(ndev);
  780. cfhsi->ndev = ndev;
  781. cfhsi->pdev = pdev;
  782. /* Initialize state vaiables. */
  783. cfhsi->tx_state = CFHSI_TX_STATE_IDLE;
  784. cfhsi->rx_state.state = CFHSI_RX_STATE_DESC;
  785. /* Set flow info */
  786. cfhsi->flow_off_sent = 0;
  787. cfhsi->q_low_mark = LOW_WATER_MARK;
  788. cfhsi->q_high_mark = HIGH_WATER_MARK;
  789. /* Assign the HSI device. */
  790. dev = (struct cfhsi_dev *)pdev->dev.platform_data;
  791. cfhsi->dev = dev;
  792. /* Assign the driver to this HSI device. */
  793. dev->drv = &cfhsi->drv;
  794. /*
  795. * Allocate a TX buffer with the size of a HSI packet descriptors
  796. * and the necessary room for CAIF payload frames.
  797. */
  798. cfhsi->tx_buf = kzalloc(CFHSI_BUF_SZ_TX, GFP_KERNEL);
  799. if (!cfhsi->tx_buf) {
  800. res = -ENODEV;
  801. goto err_alloc_tx;
  802. }
  803. /*
  804. * Allocate a RX buffer with the size of two HSI packet descriptors and
  805. * the necessary room for CAIF payload frames.
  806. */
  807. cfhsi->rx_buf = kzalloc(CFHSI_BUF_SZ_RX, GFP_KERNEL);
  808. if (!cfhsi->rx_buf) {
  809. res = -ENODEV;
  810. goto err_alloc_rx;
  811. }
  812. /* Initialize receive variables. */
  813. cfhsi->rx_ptr = cfhsi->rx_buf;
  814. cfhsi->rx_len = CFHSI_DESC_SZ;
  815. /* Initialize spin locks. */
  816. spin_lock_init(&cfhsi->lock);
  817. /* Set up the driver. */
  818. cfhsi->drv.tx_done_cb = cfhsi_tx_done_cb;
  819. cfhsi->drv.rx_done_cb = cfhsi_rx_done_cb;
  820. cfhsi->drv.wake_up_cb = cfhsi_wake_up_cb;
  821. cfhsi->drv.wake_down_cb = cfhsi_wake_down_cb;
  822. /* Initialize the work queues. */
  823. INIT_WORK(&cfhsi->wake_up_work, cfhsi_wake_up);
  824. INIT_WORK(&cfhsi->wake_down_work, cfhsi_wake_down);
  825. /* Clear all bit fields. */
  826. clear_bit(CFHSI_WAKE_UP_ACK, &cfhsi->bits);
  827. clear_bit(CFHSI_WAKE_DOWN_ACK, &cfhsi->bits);
  828. clear_bit(CFHSI_WAKE_UP, &cfhsi->bits);
  829. clear_bit(CFHSI_AWAKE, &cfhsi->bits);
  830. /* Create work thread. */
  831. cfhsi->wq = create_singlethread_workqueue(pdev->name);
  832. if (!cfhsi->wq) {
  833. dev_err(&ndev->dev, "%s: Failed to create work queue.\n",
  834. __func__);
  835. res = -ENODEV;
  836. goto err_create_wq;
  837. }
  838. /* Initialize wait queues. */
  839. init_waitqueue_head(&cfhsi->wake_up_wait);
  840. init_waitqueue_head(&cfhsi->wake_down_wait);
  841. init_waitqueue_head(&cfhsi->flush_fifo_wait);
  842. /* Setup the inactivity timer. */
  843. init_timer(&cfhsi->timer);
  844. cfhsi->timer.data = (unsigned long)cfhsi;
  845. cfhsi->timer.function = cfhsi_inactivity_tout;
  846. /* Setup the slowpath RX timer. */
  847. init_timer(&cfhsi->rx_slowpath_timer);
  848. cfhsi->rx_slowpath_timer.data = (unsigned long)cfhsi;
  849. cfhsi->rx_slowpath_timer.function = cfhsi_rx_slowpath;
  850. /* Add CAIF HSI device to list. */
  851. spin_lock(&cfhsi_list_lock);
  852. list_add_tail(&cfhsi->list, &cfhsi_list);
  853. spin_unlock(&cfhsi_list_lock);
  854. /* Activate HSI interface. */
  855. res = cfhsi->dev->cfhsi_up(cfhsi->dev);
  856. if (res) {
  857. dev_err(&cfhsi->ndev->dev,
  858. "%s: can't activate HSI interface: %d.\n",
  859. __func__, res);
  860. goto err_activate;
  861. }
  862. /* Flush FIFO */
  863. res = cfhsi_flush_fifo(cfhsi);
  864. if (res) {
  865. dev_err(&ndev->dev, "%s: Can't flush FIFO: %d.\n",
  866. __func__, res);
  867. goto err_net_reg;
  868. }
  869. /* Register network device. */
  870. res = register_netdev(ndev);
  871. if (res) {
  872. dev_err(&ndev->dev, "%s: Registration error: %d.\n",
  873. __func__, res);
  874. goto err_net_reg;
  875. }
  876. netif_stop_queue(ndev);
  877. return res;
  878. err_net_reg:
  879. cfhsi->dev->cfhsi_down(cfhsi->dev);
  880. err_activate:
  881. destroy_workqueue(cfhsi->wq);
  882. err_create_wq:
  883. kfree(cfhsi->rx_buf);
  884. err_alloc_rx:
  885. kfree(cfhsi->tx_buf);
  886. err_alloc_tx:
  887. free_netdev(ndev);
  888. return res;
  889. }
  890. static void cfhsi_shutdown(struct cfhsi *cfhsi, bool remove_platform_dev)
  891. {
  892. u8 *tx_buf, *rx_buf;
  893. /* Stop TXing */
  894. netif_tx_stop_all_queues(cfhsi->ndev);
  895. /* going to shutdown driver */
  896. set_bit(CFHSI_SHUTDOWN, &cfhsi->bits);
  897. if (remove_platform_dev) {
  898. /* Flush workqueue */
  899. flush_workqueue(cfhsi->wq);
  900. /* Notify device. */
  901. platform_device_unregister(cfhsi->pdev);
  902. }
  903. /* Flush workqueue */
  904. flush_workqueue(cfhsi->wq);
  905. /* Delete timers if pending */
  906. del_timer_sync(&cfhsi->timer);
  907. del_timer_sync(&cfhsi->rx_slowpath_timer);
  908. /* Cancel pending RX request (if any) */
  909. cfhsi->dev->cfhsi_rx_cancel(cfhsi->dev);
  910. /* Flush again and destroy workqueue */
  911. destroy_workqueue(cfhsi->wq);
  912. /* Store bufferes: will be freed later. */
  913. tx_buf = cfhsi->tx_buf;
  914. rx_buf = cfhsi->rx_buf;
  915. /* Flush transmit queues. */
  916. cfhsi_abort_tx(cfhsi);
  917. /* Deactivate interface */
  918. cfhsi->dev->cfhsi_down(cfhsi->dev);
  919. /* Finally unregister the network device. */
  920. unregister_netdev(cfhsi->ndev);
  921. /* Free buffers. */
  922. kfree(tx_buf);
  923. kfree(rx_buf);
  924. }
  925. int cfhsi_remove(struct platform_device *pdev)
  926. {
  927. struct list_head *list_node;
  928. struct list_head *n;
  929. struct cfhsi *cfhsi = NULL;
  930. struct cfhsi_dev *dev;
  931. dev = (struct cfhsi_dev *)pdev->dev.platform_data;
  932. spin_lock(&cfhsi_list_lock);
  933. list_for_each_safe(list_node, n, &cfhsi_list) {
  934. cfhsi = list_entry(list_node, struct cfhsi, list);
  935. /* Find the corresponding device. */
  936. if (cfhsi->dev == dev) {
  937. /* Remove from list. */
  938. list_del(list_node);
  939. spin_unlock(&cfhsi_list_lock);
  940. /* Shutdown driver. */
  941. cfhsi_shutdown(cfhsi, false);
  942. return 0;
  943. }
  944. }
  945. spin_unlock(&cfhsi_list_lock);
  946. return -ENODEV;
  947. }
  948. struct platform_driver cfhsi_plat_drv = {
  949. .probe = cfhsi_probe,
  950. .remove = cfhsi_remove,
  951. .driver = {
  952. .name = "cfhsi",
  953. .owner = THIS_MODULE,
  954. },
  955. };
  956. static void __exit cfhsi_exit_module(void)
  957. {
  958. struct list_head *list_node;
  959. struct list_head *n;
  960. struct cfhsi *cfhsi = NULL;
  961. spin_lock(&cfhsi_list_lock);
  962. list_for_each_safe(list_node, n, &cfhsi_list) {
  963. cfhsi = list_entry(list_node, struct cfhsi, list);
  964. /* Remove from list. */
  965. list_del(list_node);
  966. spin_unlock(&cfhsi_list_lock);
  967. /* Shutdown driver. */
  968. cfhsi_shutdown(cfhsi, true);
  969. spin_lock(&cfhsi_list_lock);
  970. }
  971. spin_unlock(&cfhsi_list_lock);
  972. /* Unregister platform driver. */
  973. platform_driver_unregister(&cfhsi_plat_drv);
  974. }
  975. static int __init cfhsi_init_module(void)
  976. {
  977. int result;
  978. /* Initialize spin lock. */
  979. spin_lock_init(&cfhsi_list_lock);
  980. /* Register platform driver. */
  981. result = platform_driver_register(&cfhsi_plat_drv);
  982. if (result) {
  983. printk(KERN_ERR "Could not register platform HSI driver: %d.\n",
  984. result);
  985. goto err_dev_register;
  986. }
  987. return result;
  988. err_dev_register:
  989. return result;
  990. }
  991. module_init(cfhsi_init_module);
  992. module_exit(cfhsi_exit_module);