0004-MIPS-lantiq-add-atm-hack.patch 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. From 9afadf01b1be371ee88491819aa67364684461f9 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Fri, 3 Aug 2012 10:27:25 +0200
  4. Subject: [PATCH 04/36] MIPS: lantiq: add atm hack
  5. Signed-off-by: John Crispin <blogic@openwrt.org>
  6. ---
  7. arch/mips/include/asm/mach-lantiq/lantiq_atm.h | 196 +++++++++++++++++++++++
  8. arch/mips/include/asm/mach-lantiq/lantiq_ptm.h | 203 ++++++++++++++++++++++++
  9. arch/mips/lantiq/irq.c | 2 +
  10. arch/mips/mm/cache.c | 2 +
  11. include/uapi/linux/atm.h | 6 +
  12. net/atm/common.c | 6 +
  13. net/atm/proc.c | 2 +-
  14. 7 files changed, 416 insertions(+), 1 deletion(-)
  15. create mode 100644 arch/mips/include/asm/mach-lantiq/lantiq_atm.h
  16. create mode 100644 arch/mips/include/asm/mach-lantiq/lantiq_ptm.h
  17. --- /dev/null
  18. +++ b/arch/mips/include/asm/mach-lantiq/lantiq_atm.h
  19. @@ -0,0 +1,196 @@
  20. +/******************************************************************************
  21. +**
  22. +** FILE NAME : ifx_atm.h
  23. +** PROJECT : UEIP
  24. +** MODULES : ATM
  25. +**
  26. +** DATE : 17 Jun 2009
  27. +** AUTHOR : Xu Liang
  28. +** DESCRIPTION : Global ATM driver header file
  29. +** COPYRIGHT : Copyright (c) 2006
  30. +** Infineon Technologies AG
  31. +** Am Campeon 1-12, 85579 Neubiberg, Germany
  32. +**
  33. +** This program is free software; you can redistribute it and/or modify
  34. +** it under the terms of the GNU General Public License as published by
  35. +** the Free Software Foundation; either version 2 of the License, or
  36. +** (at your option) any later version.
  37. +**
  38. +** HISTORY
  39. +** $Date $Author $Comment
  40. +** 07 JUL 2009 Xu Liang Init Version
  41. +*******************************************************************************/
  42. +
  43. +#ifndef IFX_ATM_H
  44. +#define IFX_ATM_H
  45. +
  46. +
  47. +
  48. +/*!
  49. + \defgroup IFX_ATM UEIP Project - ATM driver module
  50. + \brief UEIP Project - ATM driver module, support Danube, Amazon-SE, AR9, VR9.
  51. + */
  52. +
  53. +/*!
  54. + \defgroup IFX_ATM_IOCTL IOCTL Commands
  55. + \ingroup IFX_ATM
  56. + \brief IOCTL Commands used by user application.
  57. + */
  58. +
  59. +/*!
  60. + \defgroup IFX_ATM_STRUCT Structures
  61. + \ingroup IFX_ATM
  62. + \brief Structures used by user application.
  63. + */
  64. +
  65. +/*!
  66. + \file ifx_atm.h
  67. + \ingroup IFX_ATM
  68. + \brief ATM driver header file
  69. + */
  70. +
  71. +
  72. +
  73. +/*
  74. + * ####################################
  75. + * Definition
  76. + * ####################################
  77. + */
  78. +
  79. +/*!
  80. + \addtogroup IFX_ATM_STRUCT
  81. + */
  82. +/*@{*/
  83. +
  84. +/*
  85. + * ATM MIB
  86. + */
  87. +
  88. +/*!
  89. + \struct atm_cell_ifEntry_t
  90. + \brief Structure used for Cell Level MIB Counters.
  91. +
  92. + User application use this structure to call IOCTL command "PPE_ATM_MIB_CELL".
  93. + */
  94. +typedef struct {
  95. + __u32 ifHCInOctets_h; /*!< byte counter of ingress cells (upper 32 bits, total 64 bits) */
  96. + __u32 ifHCInOctets_l; /*!< byte counter of ingress cells (lower 32 bits, total 64 bits) */
  97. + __u32 ifHCOutOctets_h; /*!< byte counter of egress cells (upper 32 bits, total 64 bits) */
  98. + __u32 ifHCOutOctets_l; /*!< byte counter of egress cells (lower 32 bits, total 64 bits) */
  99. + __u32 ifInErrors; /*!< counter of error ingress cells */
  100. + __u32 ifInUnknownProtos; /*!< counter of unknown ingress cells */
  101. + __u32 ifOutErrors; /*!< counter of error egress cells */
  102. +} atm_cell_ifEntry_t;
  103. +
  104. +/*!
  105. + \struct atm_aal5_ifEntry_t
  106. + \brief Structure used for AAL5 Frame Level MIB Counters.
  107. +
  108. + User application use this structure to call IOCTL command "PPE_ATM_MIB_AAL5".
  109. + */
  110. +typedef struct {
  111. + __u32 ifHCInOctets_h; /*!< byte counter of ingress packets (upper 32 bits, total 64 bits) */
  112. + __u32 ifHCInOctets_l; /*!< byte counter of ingress packets (lower 32 bits, total 64 bits) */
  113. + __u32 ifHCOutOctets_h; /*!< byte counter of egress packets (upper 32 bits, total 64 bits) */
  114. + __u32 ifHCOutOctets_l; /*!< byte counter of egress packets (lower 32 bits, total 64 bits) */
  115. + __u32 ifInUcastPkts; /*!< counter of ingress packets */
  116. + __u32 ifOutUcastPkts; /*!< counter of egress packets */
  117. + __u32 ifInErrors; /*!< counter of error ingress packets */
  118. + __u32 ifInDiscards; /*!< counter of dropped ingress packets */
  119. + __u32 ifOutErros; /*!< counter of error egress packets */
  120. + __u32 ifOutDiscards; /*!< counter of dropped egress packets */
  121. +} atm_aal5_ifEntry_t;
  122. +
  123. +/*!
  124. + \struct atm_aal5_vcc_t
  125. + \brief Structure used for per PVC AAL5 Frame Level MIB Counters.
  126. +
  127. + This structure is a part of structure "atm_aal5_vcc_x_t".
  128. + */
  129. +typedef struct {
  130. + __u32 aal5VccCrcErrors; /*!< counter of ingress packets with CRC error */
  131. + __u32 aal5VccSarTimeOuts; /*!< counter of ingress packets with Re-assemble timeout */ //no timer support yet
  132. + __u32 aal5VccOverSizedSDUs; /*!< counter of oversized ingress packets */
  133. +} atm_aal5_vcc_t;
  134. +
  135. +/*!
  136. + \struct atm_aal5_vcc_x_t
  137. + \brief Structure used for per PVC AAL5 Frame Level MIB Counters.
  138. +
  139. + User application use this structure to call IOCTL command "PPE_ATM_MIB_VCC".
  140. + */
  141. +typedef struct {
  142. + int vpi; /*!< VPI of the VCC to get MIB counters */
  143. + int vci; /*!< VCI of the VCC to get MIB counters */
  144. + atm_aal5_vcc_t mib_vcc; /*!< structure to get MIB counters */
  145. +} atm_aal5_vcc_x_t;
  146. +
  147. +/*@}*/
  148. +
  149. +
  150. +
  151. +/*
  152. + * ####################################
  153. + * IOCTL
  154. + * ####################################
  155. + */
  156. +
  157. +/*!
  158. + \addtogroup IFX_ATM_IOCTL
  159. + */
  160. +/*@{*/
  161. +
  162. +/*
  163. + * ioctl Command
  164. + */
  165. +/*!
  166. + \brief ATM IOCTL Magic Number
  167. + */
  168. +#define PPE_ATM_IOC_MAGIC 'o'
  169. +/*!
  170. + \brief ATM IOCTL Command - Get Cell Level MIB Counters
  171. +
  172. + This command is obsolete. User can get cell level MIB from DSL API.
  173. + This command uses structure "atm_cell_ifEntry_t" as parameter for output of MIB counters.
  174. + */
  175. +#define PPE_ATM_MIB_CELL _IOW(PPE_ATM_IOC_MAGIC, 0, atm_cell_ifEntry_t)
  176. +/*!
  177. + \brief ATM IOCTL Command - Get AAL5 Level MIB Counters
  178. +
  179. + Get AAL5 packet counters.
  180. + This command uses structure "atm_aal5_ifEntry_t" as parameter for output of MIB counters.
  181. + */
  182. +#define PPE_ATM_MIB_AAL5 _IOW(PPE_ATM_IOC_MAGIC, 1, atm_aal5_ifEntry_t)
  183. +/*!
  184. + \brief ATM IOCTL Command - Get Per PVC MIB Counters
  185. +
  186. + Get AAL5 packet counters for each PVC.
  187. + This command uses structure "atm_aal5_vcc_x_t" as parameter for input of VPI/VCI information and output of MIB counters.
  188. + */
  189. +#define PPE_ATM_MIB_VCC _IOWR(PPE_ATM_IOC_MAGIC, 2, atm_aal5_vcc_x_t)
  190. +/*!
  191. + \brief Total Number of ATM IOCTL Commands
  192. + */
  193. +#define PPE_ATM_IOC_MAXNR 3
  194. +
  195. +/*@}*/
  196. +
  197. +
  198. +
  199. +/*
  200. + * ####################################
  201. + * API
  202. + * ####################################
  203. + */
  204. +
  205. +#ifdef __KERNEL__
  206. +struct port_cell_info {
  207. + unsigned int port_num;
  208. + unsigned int tx_link_rate[2];
  209. +};
  210. +#endif
  211. +
  212. +
  213. +
  214. +#endif // IFX_ATM_H
  215. +
  216. --- /dev/null
  217. +++ b/arch/mips/include/asm/mach-lantiq/lantiq_ptm.h
  218. @@ -0,0 +1,203 @@
  219. +/******************************************************************************
  220. +**
  221. +** FILE NAME : ifx_ptm.h
  222. +** PROJECT : UEIP
  223. +** MODULES : PTM
  224. +**
  225. +** DATE : 17 Jun 2009
  226. +** AUTHOR : Xu Liang
  227. +** DESCRIPTION : Global PTM driver header file
  228. +** COPYRIGHT : Copyright (c) 2006
  229. +** Infineon Technologies AG
  230. +** Am Campeon 1-12, 85579 Neubiberg, Germany
  231. +**
  232. +** This program is free software; you can redistribute it and/or modify
  233. +** it under the terms of the GNU General Public License as published by
  234. +** the Free Software Foundation; either version 2 of the License, or
  235. +** (at your option) any later version.
  236. +**
  237. +** HISTORY
  238. +** $Date $Author $Comment
  239. +** 07 JUL 2009 Xu Liang Init Version
  240. +*******************************************************************************/
  241. +
  242. +#ifndef IFX_PTM_H
  243. +#define IFX_PTM_H
  244. +
  245. +
  246. +
  247. +/*!
  248. + \defgroup IFX_PTM UEIP Project - PTM driver module
  249. + \brief UEIP Project - PTM driver module, support Danube, Amazon-SE, AR9, VR9.
  250. + */
  251. +
  252. +/*!
  253. + \defgroup IFX_PTM_IOCTL IOCTL Commands
  254. + \ingroup IFX_PTM
  255. + \brief IOCTL Commands used by user application.
  256. + */
  257. +
  258. +/*!
  259. + \defgroup IFX_PTM_STRUCT Structures
  260. + \ingroup IFX_PTM
  261. + \brief Structures used by user application.
  262. + */
  263. +
  264. +/*!
  265. + \file ifx_ptm.h
  266. + \ingroup IFX_PTM
  267. + \brief PTM driver header file
  268. + */
  269. +
  270. +
  271. +
  272. +/*
  273. + * ####################################
  274. + * Definition
  275. + * ####################################
  276. + */
  277. +
  278. +
  279. +
  280. +/*
  281. + * ####################################
  282. + * IOCTL
  283. + * ####################################
  284. + */
  285. +
  286. +/*!
  287. + \addtogroup IFX_PTM_IOCTL
  288. + */
  289. +/*@{*/
  290. +
  291. +/*
  292. + * ioctl Command
  293. + */
  294. +/*!
  295. + \brief PTM IOCTL Command - Get codeword MIB counters.
  296. +
  297. + This command uses structure "PTM_CW_IF_ENTRY_T" to get codeword level MIB counters.
  298. + */
  299. +#define IFX_PTM_MIB_CW_GET SIOCDEVPRIVATE + 1
  300. +/*!
  301. + \brief PTM IOCTL Command - Get packet MIB counters.
  302. +
  303. + This command uses structure "PTM_FRAME_MIB_T" to get packet level MIB counters.
  304. + */
  305. +#define IFX_PTM_MIB_FRAME_GET SIOCDEVPRIVATE + 2
  306. +/*!
  307. + \brief PTM IOCTL Command - Get firmware configuration (CRC).
  308. +
  309. + This command uses structure "IFX_PTM_CFG_T" to get firmware configuration (CRC).
  310. + */
  311. +#define IFX_PTM_CFG_GET SIOCDEVPRIVATE + 3
  312. +/*!
  313. + \brief PTM IOCTL Command - Set firmware configuration (CRC).
  314. +
  315. + This command uses structure "IFX_PTM_CFG_T" to set firmware configuration (CRC).
  316. + */
  317. +#define IFX_PTM_CFG_SET SIOCDEVPRIVATE + 4
  318. +/*!
  319. + \brief PTM IOCTL Command - Program priority value to TX queue mapping.
  320. +
  321. + This command uses structure "IFX_PTM_PRIO_Q_MAP_T" to program priority value to TX queue mapping.
  322. + */
  323. +#define IFX_PTM_MAP_PKT_PRIO_TO_Q SIOCDEVPRIVATE + 14
  324. +
  325. +/*@}*/
  326. +
  327. +
  328. +/*!
  329. + \addtogroup IFX_PTM_STRUCT
  330. + */
  331. +/*@{*/
  332. +
  333. +/*
  334. + * ioctl Data Type
  335. + */
  336. +
  337. +/*!
  338. + \typedef PTM_CW_IF_ENTRY_T
  339. + \brief Wrapping of structure "ptm_cw_ifEntry_t".
  340. + */
  341. +/*!
  342. + \struct ptm_cw_ifEntry_t
  343. + \brief Structure used for CodeWord level MIB counters.
  344. + */
  345. +typedef struct ptm_cw_ifEntry_t {
  346. + uint32_t ifRxNoIdleCodewords; /*!< output, number of ingress user codeword */
  347. + uint32_t ifRxIdleCodewords; /*!< output, number of ingress idle codeword */
  348. + uint32_t ifRxCodingViolation; /*!< output, number of error ingress codeword */
  349. + uint32_t ifTxNoIdleCodewords; /*!< output, number of egress user codeword */
  350. + uint32_t ifTxIdleCodewords; /*!< output, number of egress idle codeword */
  351. +} PTM_CW_IF_ENTRY_T;
  352. +
  353. +/*!
  354. + \typedef PTM_FRAME_MIB_T
  355. + \brief Wrapping of structure "ptm_frame_mib_t".
  356. + */
  357. +/*!
  358. + \struct ptm_frame_mib_t
  359. + \brief Structure used for packet level MIB counters.
  360. + */
  361. +typedef struct ptm_frame_mib_t {
  362. + uint32_t RxCorrect; /*!< output, number of ingress packet */
  363. + uint32_t TC_CrcError; /*!< output, number of egress packet with CRC error */
  364. + uint32_t RxDropped; /*!< output, number of dropped ingress packet */
  365. + uint32_t TxSend; /*!< output, number of egress packet */
  366. +} PTM_FRAME_MIB_T;
  367. +
  368. +/*!
  369. + \typedef IFX_PTM_CFG_T
  370. + \brief Wrapping of structure "ptm_cfg_t".
  371. + */
  372. +/*!
  373. + \struct ptm_cfg_t
  374. + \brief Structure used for ETH/TC CRC configuration.
  375. + */
  376. +typedef struct ptm_cfg_t {
  377. + uint32_t RxEthCrcPresent; /*!< input/output, ingress packet has ETH CRC */
  378. + uint32_t RxEthCrcCheck; /*!< input/output, check ETH CRC of ingress packet */
  379. + uint32_t RxTcCrcCheck; /*!< input/output, check TC CRC of ingress codeword */
  380. + uint32_t RxTcCrcLen; /*!< input/output, length of TC CRC of ingress codeword */
  381. + uint32_t TxEthCrcGen; /*!< input/output, generate ETH CRC for egress packet */
  382. + uint32_t TxTcCrcGen; /*!< input/output, generate TC CRC for egress codeword */
  383. + uint32_t TxTcCrcLen; /*!< input/output, length of TC CRC of egress codeword */
  384. +} IFX_PTM_CFG_T;
  385. +
  386. +/*!
  387. + \typedef IFX_PTM_PRIO_Q_MAP_T
  388. + \brief Wrapping of structure "ppe_prio_q_map".
  389. + */
  390. +/*!
  391. + \struct ppe_prio_q_map
  392. + \brief Structure used for Priority Value to TX Queue mapping.
  393. + */
  394. +typedef struct ppe_prio_q_map {
  395. + int pkt_prio;
  396. + int qid;
  397. + int vpi; // ignored in eth interface
  398. + int vci; // ignored in eth interface
  399. +} IFX_PTM_PRIO_Q_MAP_T;
  400. +
  401. +/*@}*/
  402. +
  403. +
  404. +
  405. +/*
  406. + * ####################################
  407. + * API
  408. + * ####################################
  409. + */
  410. +
  411. +#ifdef __KERNEL__
  412. +struct port_cell_info {
  413. + unsigned int port_num;
  414. + unsigned int tx_link_rate[2];
  415. +};
  416. +#endif
  417. +
  418. +
  419. +
  420. +#endif // IFX_PTM_H
  421. +
  422. --- a/arch/mips/lantiq/irq.c
  423. +++ b/arch/mips/lantiq/irq.c
  424. @@ -14,6 +14,7 @@
  425. #include <linux/of_platform.h>
  426. #include <linux/of_address.h>
  427. #include <linux/of_irq.h>
  428. +#include <linux/module.h>
  429. #include <asm/bootinfo.h>
  430. #include <asm/irq_cpu.h>
  431. @@ -100,6 +101,7 @@ void ltq_mask_and_ack_irq(struct irq_dat
  432. ltq_icu_w32(im, ltq_icu_r32(im, ier) & ~BIT(offset), ier);
  433. ltq_icu_w32(im, BIT(offset), isr);
  434. }
  435. +EXPORT_SYMBOL(ltq_mask_and_ack_irq);
  436. static void ltq_ack_irq(struct irq_data *d)
  437. {
  438. --- a/arch/mips/mm/cache.c
  439. +++ b/arch/mips/mm/cache.c
  440. @@ -59,6 +59,8 @@ void (*_dma_cache_wback)(unsigned long s
  441. void (*_dma_cache_inv)(unsigned long start, unsigned long size);
  442. EXPORT_SYMBOL(_dma_cache_wback_inv);
  443. +EXPORT_SYMBOL(_dma_cache_wback);
  444. +EXPORT_SYMBOL(_dma_cache_inv);
  445. #endif /* CONFIG_DMA_NONCOHERENT || CONFIG_DMA_MAYBE_COHERENT */
  446. --- a/include/uapi/linux/atm.h
  447. +++ b/include/uapi/linux/atm.h
  448. @@ -130,8 +130,14 @@
  449. #define ATM_ABR 4
  450. #define ATM_ANYCLASS 5 /* compatible with everything */
  451. +#define ATM_VBR_NRT ATM_VBR
  452. +#define ATM_VBR_RT 6
  453. +#define ATM_UBR_PLUS 7
  454. +#define ATM_GFR 8
  455. +
  456. #define ATM_MAX_PCR -1 /* maximum available PCR */
  457. +
  458. struct atm_trafprm {
  459. unsigned char traffic_class; /* traffic class (ATM_UBR, ...) */
  460. int max_pcr; /* maximum PCR in cells per second */
  461. --- a/net/atm/common.c
  462. +++ b/net/atm/common.c
  463. @@ -62,11 +62,17 @@ static void vcc_remove_socket(struct soc
  464. write_unlock_irq(&vcc_sklist_lock);
  465. }
  466. +struct sk_buff* (*ifx_atm_alloc_tx)(struct atm_vcc *, unsigned int) = NULL;
  467. +EXPORT_SYMBOL(ifx_atm_alloc_tx);
  468. +
  469. static struct sk_buff *alloc_tx(struct atm_vcc *vcc, unsigned int size)
  470. {
  471. struct sk_buff *skb;
  472. struct sock *sk = sk_atm(vcc);
  473. + if (ifx_atm_alloc_tx != NULL)
  474. + return ifx_atm_alloc_tx(vcc, size);
  475. +
  476. if (sk_wmem_alloc_get(sk) && !atm_may_send(vcc, size)) {
  477. pr_debug("Sorry: wmem_alloc = %d, size = %d, sndbuf = %d\n",
  478. sk_wmem_alloc_get(sk), size, sk->sk_sndbuf);
  479. --- a/net/atm/proc.c
  480. +++ b/net/atm/proc.c
  481. @@ -154,7 +154,7 @@ static void *vcc_seq_next(struct seq_fil
  482. static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc)
  483. {
  484. static const char *const class_name[] = {
  485. - "off", "UBR", "CBR", "VBR", "ABR"};
  486. + "off","UBR","CBR","NTR-VBR","ABR","ANY","RT-VBR","UBR+","GFR"};
  487. static const char *const aal_name[] = {
  488. "---", "1", "2", "3/4", /* 0- 3 */
  489. "???", "5", "???", "???", /* 4- 7 */