1 /******************************************************************************
3 ** FILE NAME : ifxmips_atm_core.c
9 ** DESCRIPTION : ATM driver common source file (core functions)
10 ** COPYRIGHT : Copyright (c) 2006
11 ** Infineon Technologies AG
12 ** Am Campeon 1-12, 85579 Neubiberg, Germany
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 of the License, or
17 ** (at your option) any later version.
20 ** $Date $Author $Comment
21 ** 07 JUL 2009 Xu Liang Init Version
22 *******************************************************************************/
27 * ####################################
29 * ####################################
32 #define IFX_ATM_VER_MAJOR 1
33 #define IFX_ATM_VER_MID 0
34 #define IFX_ATM_VER_MINOR 19
39 * ####################################
41 * ####################################
47 #include <linux/kernel.h>
48 #include <linux/vmalloc.h>
49 #include <linux/module.h>
50 #include <linux/version.h>
51 #include <linux/types.h>
52 #include <linux/errno.h>
53 #include <linux/proc_fs.h>
54 #include <linux/init.h>
55 #include <linux/ioctl.h>
56 #include <linux/atmdev.h>
57 #include <linux/atm.h>
58 #include <linux/clk.h>
59 #include <linux/interrupt.h>
62 * Chip Specific Head File
64 #include <lantiq_soc.h>
65 #include "ifxmips_compat.h"
67 #include "ifxmips_mei_interface.h"
68 #include "ifxmips_atm_core.h"
73 * ####################################
74 * Kernel Version Adaption
75 * ####################################
77 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
78 #define MODULE_PARM_ARRAY(a, b) module_param_array(a, int, NULL, 0)
79 #define MODULE_PARM(a, b) module_param(a, int, 0)
81 #define MODULE_PARM_ARRAY(a, b) MODULE_PARM(a, b)
87 \addtogroup IFXMIPS_ATM_MODULE_PARAMS
91 * ####################################
92 * Parameters to Configure PPE
93 * ####################################
96 \brief QSB cell delay variation due to concurrency
98 static int qsb_tau
= 1; /* QSB cell delay variation due to concurrency */
100 \brief QSB scheduler burst length
102 static int qsb_srvm
= 0x0F; /* QSB scheduler burst length */
104 \brief QSB time step, all legal values are 1, 2, 4
106 static int qsb_tstep
= 4 ; /* QSB time step, all legal values are 1, 2, 4 */
109 \brief Write descriptor delay
111 static int write_descriptor_delay
= 0x20; /* Write descriptor delay */
114 \brief AAL5 padding byte ('~')
116 static int aal5_fill_pattern
= 0x007E; /* AAL5 padding byte ('~') */
118 \brief Max frame size for RX
120 static int aal5r_max_packet_size
= 0x0700; /* Max frame size for RX */
122 \brief Min frame size for RX
124 static int aal5r_min_packet_size
= 0x0000; /* Min frame size for RX */
126 \brief Max frame size for TX
128 static int aal5s_max_packet_size
= 0x0700; /* Max frame size for TX */
130 \brief Min frame size for TX
132 static int aal5s_min_packet_size
= 0x0000; /* Min frame size for TX */
134 \brief Drop error packet in RX path
136 static int aal5r_drop_error_packet
= 1; /* Drop error packet in RX path */
139 \brief Number of descriptors per DMA RX channel
141 static int dma_rx_descriptor_length
= 128; /* Number of descriptors per DMA RX channel */
143 \brief Number of descriptors per DMA TX channel
145 static int dma_tx_descriptor_length
= 64; /* Number of descriptors per DMA TX channel */
147 \brief PPE core clock cycles between descriptor write and effectiveness in external RAM
149 static int dma_rx_clp1_descriptor_threshold
= 38;
152 MODULE_PARM(qsb_tau
, "i");
153 MODULE_PARM_DESC(qsb_tau
, "Cell delay variation. Value must be > 0");
154 MODULE_PARM(qsb_srvm
, "i");
155 MODULE_PARM_DESC(qsb_srvm
, "Maximum burst size");
156 MODULE_PARM(qsb_tstep
, "i");
157 MODULE_PARM_DESC(qsb_tstep
, "n*32 cycles per sbs cycles n=1,2,4");
159 MODULE_PARM(write_descriptor_delay
, "i");
160 MODULE_PARM_DESC(write_descriptor_delay
, "PPE core clock cycles between descriptor write and effectiveness in external RAM");
162 MODULE_PARM(aal5_fill_pattern
, "i");
163 MODULE_PARM_DESC(aal5_fill_pattern
, "Filling pattern (PAD) for AAL5 frames");
164 MODULE_PARM(aal5r_max_packet_size
, "i");
165 MODULE_PARM_DESC(aal5r_max_packet_size
, "Max packet size in byte for downstream AAL5 frames");
166 MODULE_PARM(aal5r_min_packet_size
, "i");
167 MODULE_PARM_DESC(aal5r_min_packet_size
, "Min packet size in byte for downstream AAL5 frames");
168 MODULE_PARM(aal5s_max_packet_size
, "i");
169 MODULE_PARM_DESC(aal5s_max_packet_size
, "Max packet size in byte for upstream AAL5 frames");
170 MODULE_PARM(aal5s_min_packet_size
, "i");
171 MODULE_PARM_DESC(aal5s_min_packet_size
, "Min packet size in byte for upstream AAL5 frames");
172 MODULE_PARM(aal5r_drop_error_packet
, "i");
173 MODULE_PARM_DESC(aal5r_drop_error_packet
, "Non-zero value to drop error packet for downstream");
175 MODULE_PARM(dma_rx_descriptor_length
, "i");
176 MODULE_PARM_DESC(dma_rx_descriptor_length
, "Number of descriptor assigned to DMA RX channel (>16)");
177 MODULE_PARM(dma_tx_descriptor_length
, "i");
178 MODULE_PARM_DESC(dma_tx_descriptor_length
, "Number of descriptor assigned to DMA TX channel (>16)");
179 MODULE_PARM(dma_rx_clp1_descriptor_threshold
, "i");
180 MODULE_PARM_DESC(dma_rx_clp1_descriptor_threshold
, "Descriptor threshold for cells with cell loss priority 1");
185 * ####################################
187 * ####################################
190 #define ENABLE_LED_FRAMEWORK 1
192 #define DUMP_SKB_LEN ~0
197 * ####################################
199 * ####################################
205 static int ppe_ioctl(struct atm_dev
*, unsigned int, void *);
206 static int ppe_open(struct atm_vcc
*);
207 static void ppe_close(struct atm_vcc
*);
208 static int ppe_send(struct atm_vcc
*, struct sk_buff
*);
209 static int ppe_send_oam(struct atm_vcc
*, void *, int);
210 static int ppe_change_qos(struct atm_vcc
*, struct atm_qos
*, int);
215 static INLINE
void adsl_led_flash(void);
218 * 64-bit operation used by MIB calculation
220 static INLINE
void u64_add_u32(ppe_u64_t
, unsigned int, ppe_u64_t
*);
223 * buffer manage functions
225 static INLINE
struct sk_buff
* alloc_skb_rx(void);
226 static INLINE
struct sk_buff
* alloc_skb_tx(unsigned int);
227 struct sk_buff
* atm_alloc_tx(struct atm_vcc
*, unsigned int);
228 static INLINE
void atm_free_tx_skb_vcc(struct sk_buff
*, struct atm_vcc
*);
229 static INLINE
struct sk_buff
*get_skb_rx_pointer(unsigned int);
230 static INLINE
int get_tx_desc(unsigned int);
233 * mailbox handler and signal function
235 static INLINE
void mailbox_oam_rx_handler(void);
236 static INLINE
void mailbox_aal_rx_handler(void);
237 #if defined(ENABLE_TASKLET) && ENABLE_TASKLET
238 static void do_ppe_tasklet(unsigned long);
240 static irqreturn_t
mailbox_irq_handler(int, void *);
241 static INLINE
void mailbox_signal(unsigned int, int);
244 * QSB & HTU setting functions
246 static void set_qsb(struct atm_vcc
*, struct atm_qos
*, unsigned int);
247 static void qsb_global_set(void);
248 static INLINE
void set_htu_entry(unsigned int, unsigned int, unsigned int, int, int);
249 static INLINE
void clear_htu_entry(unsigned int);
250 static void validate_oam_htu_entry(void);
251 static void invalidate_oam_htu_entry(void);
254 * look up for connection ID
256 static INLINE
int find_vpi(unsigned int);
257 static INLINE
int find_vpivci(unsigned int, unsigned int);
258 static INLINE
int find_vcc(struct atm_vcc
*);
263 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
264 static void retx_polling_func(unsigned long);
265 static int init_atm_tc_retrans_param(void);
266 static void clear_atm_tc_retrans_param(void);
273 #if defined(DEBUG_DUMP_SKB) && DEBUG_DUMP_SKB
274 static void dump_skb(struct sk_buff
*, unsigned int, char *, int, int, int);
276 #define dump_skb(skb, len, title, port, ch, is_tx) do {} while (0)
278 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
279 static void skb_swap(struct sk_buff
*, unsigned int);
281 #define skb_swap(skb, byteoff) do {} while (0)
285 * Proc File Functions
287 static INLINE
void proc_file_create(void);
288 static INLINE
void proc_file_delete(void);
289 static int proc_read_version(char *, char **, off_t
, int, int *, void *);
290 static int proc_read_mib(char *, char **, off_t
, int, int *, void *);
291 static int proc_write_mib(struct file
*, const char *, unsigned long, void *);
292 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
293 static int proc_read_retx_mib(char *, char **, off_t
, int, int *, void *);
294 static int proc_write_retx_mib(struct file
*, const char *, unsigned long, void *);
296 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
297 static int proc_read_dbg(char *, char **, off_t
, int, int *, void *);
298 static int proc_write_dbg(struct file
*, const char *, unsigned long, void *);
299 static int proc_write_mem(struct file
*, const char *, unsigned long, void *);
300 #if defined(CONFIG_AR9) || defined(CONFIG_VR9) || defined(CONFIG_DANUBE) || defined(CONFIG_AMAZON_SE)
301 static int proc_read_pp32(char *, char **, off_t
, int, int *, void *);
302 static int proc_write_pp32(struct file
*, const char *, unsigned long, void *);
305 #if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
306 static int proc_read_htu(char *, char **, off_t
, int, int *, void *);
307 static int proc_read_txq(char *, char **, off_t
, int, int *, void *);
308 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
309 static int proc_read_retx_fw(char *, char **, off_t
, int, int *, void *);
310 static int proc_read_retx_stats(char *, char **, off_t
, int, int *, void *);
311 static int proc_write_retx_stats(struct file
*, const char *, unsigned long, void *);
312 static int proc_read_retx_cfg(char *, char **, off_t
, int, int *, void *);
313 static int proc_write_retx_cfg(struct file
*, const char *, unsigned long, void *);
314 static int proc_read_retx_dsl_param(char *, char **, off_t
, int, int *, void *);
319 * Proc Help Functions
321 static int stricmp(const char *, const char *);
322 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
323 static int strincmp(const char *, const char *, int);
324 static int get_token(char **, char **, int *, int *);
325 static unsigned int get_number(char **, int *, int);
326 static void ignore_space(char **, int *);
328 static INLINE
int ifx_atm_version(char *);
331 * Init & clean-up functions
333 static INLINE
void check_parameters(void);
334 static INLINE
int init_priv_data(void);
335 static INLINE
void clear_priv_data(void);
336 static INLINE
void init_rx_tables(void);
337 static INLINE
void init_tx_tables(void);
342 #if defined(CONFIG_IFX_OAM) || defined(CONFIG_IFX_OAM_MODULE)
343 extern void ifx_push_oam(unsigned char *);
345 static inline void ifx_push_oam(unsigned char *dummy
) {}
347 #if defined(CONFIG_IFXMIPS_DSL_CPE_MEI) || defined(CONFIG_IFXMIPS_DSL_CPE_MEI_MODULE)
348 #if !defined(ENABLE_LED_FRAMEWORK) || !ENABLE_LED_FRAMEWORK
349 extern int ifx_mei_atm_led_blink(void) __attribute__ ((weak
));
351 extern int ifx_mei_atm_showtime_check(int *is_showtime
, struct port_cell_info
*port_cell
, void **xdata_addr
) __attribute__ ((weak
));
353 #if !defined(ENABLE_LED_FRAMEWORK) || !ENABLE_LED_FRAMEWORK
354 static inline int ifx_mei_atm_led_blink(void) { return IFX_SUCCESS
; }
356 static inline int ifx_mei_atm_showtime_check(int *is_showtime
, struct port_cell_info
*port_cell
, void **xdata_addr
)
358 if ( is_showtime
!= NULL
)
367 struct sk_buff
* (*ifx_atm_alloc_tx
)(struct atm_vcc
*, unsigned int) = NULL
;
370 //extern struct sk_buff* (*ifx_atm_alloc_tx)(struct atm_vcc *, unsigned int);
371 #if defined(CONFIG_IFXMIPS_DSL_CPE_MEI) || defined(CONFIG_IFXMIPS_DSL_CPE_MEI_MODULE)
372 extern int (*ifx_mei_atm_showtime_enter
)(struct port_cell_info
*, void *) __attribute__ ((weak
));
373 extern int (*ifx_mei_atm_showtime_exit
)(void) __attribute__ ((weak
));
375 int (*ifx_mei_atm_showtime_enter
)(struct port_cell_info
*, void *) = NULL
;
376 EXPORT_SYMBOL(ifx_mei_atm_showtime_enter
);
377 int (*ifx_mei_atm_showtime_exit
)(void) = NULL
;
378 EXPORT_SYMBOL(ifx_mei_atm_showtime_exit
);
384 * ####################################
386 * ####################################
389 static struct atm_priv_data g_atm_priv_data
;
391 static struct atmdev_ops g_ifx_atm_ops
= {
396 .send_oam
= ppe_send_oam
,
397 .change_qos
= ppe_change_qos
,
398 .owner
= THIS_MODULE
,
401 #if defined(ENABLE_TASKLET) && ENABLE_TASKLET
402 DECLARE_TASKLET(g_dma_tasklet
, do_ppe_tasklet
, 0);
405 static int g_showtime
= 0;
406 static void *g_xdata_addr
= NULL
;
408 #if 0 /*--- defined(ENABLE_LED_FRAMEWORK) && ENABLE_LED_FRAMEWORK ---*/
409 static void *g_data_led_trigger
= NULL
;
412 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
413 static unsigned long g_retx_playout_buffer
= 0;
415 static volatile int g_retx_htu
= 1;
416 static struct dsl_param g_dsl_param
= {0};
417 static int g_retx_polling_cnt
= HZ
;
418 static struct timeval g_retx_polling_start
= {0}, g_retx_polling_end
= {0};
419 static struct timer_list g_retx_polling_timer
;
422 unsigned int ifx_atm_dbg_enable
= 0;
424 static struct proc_dir_entry
* g_atm_dir
= NULL
;
429 * ####################################
431 * ####################################
434 static int ppe_ioctl(struct atm_dev
*dev
, unsigned int cmd
, void *arg
)
437 atm_cell_ifEntry_t mib_cell
;
438 atm_aal5_ifEntry_t mib_aal5
;
439 atm_aal5_vcc_x_t mib_vcc
;
443 if ( _IOC_TYPE(cmd
) != PPE_ATM_IOC_MAGIC
444 || _IOC_NR(cmd
) >= PPE_ATM_IOC_MAXNR
)
447 if ( _IOC_DIR(cmd
) & _IOC_READ
)
448 ret
= !access_ok(VERIFY_WRITE
, arg
, _IOC_SIZE(cmd
));
449 else if ( _IOC_DIR(cmd
) & _IOC_WRITE
)
450 ret
= !access_ok(VERIFY_READ
, arg
, _IOC_SIZE(cmd
));
456 case PPE_ATM_MIB_CELL
: /* cell level MIB */
457 /* These MIB should be read at ARC side, now put zero only. */
458 mib_cell
.ifHCInOctets_h
= 0;
459 mib_cell
.ifHCInOctets_l
= 0;
460 mib_cell
.ifHCOutOctets_h
= 0;
461 mib_cell
.ifHCOutOctets_l
= 0;
462 mib_cell
.ifInErrors
= 0;
463 mib_cell
.ifInUnknownProtos
= WAN_MIB_TABLE
->wrx_drophtu_cell
;
464 mib_cell
.ifOutErrors
= 0;
466 ret
= sizeof(mib_cell
) - copy_to_user(arg
, &mib_cell
, sizeof(mib_cell
));
469 case PPE_ATM_MIB_AAL5
: /* AAL5 MIB */
470 value
= WAN_MIB_TABLE
->wrx_total_byte
;
471 u64_add_u32(g_atm_priv_data
.wrx_total_byte
, value
- g_atm_priv_data
.prev_wrx_total_byte
, &g_atm_priv_data
.wrx_total_byte
);
472 g_atm_priv_data
.prev_wrx_total_byte
= value
;
473 mib_aal5
.ifHCInOctets_h
= g_atm_priv_data
.wrx_total_byte
.h
;
474 mib_aal5
.ifHCInOctets_l
= g_atm_priv_data
.wrx_total_byte
.l
;
476 value
= WAN_MIB_TABLE
->wtx_total_byte
;
477 u64_add_u32(g_atm_priv_data
.wtx_total_byte
, value
- g_atm_priv_data
.prev_wtx_total_byte
, &g_atm_priv_data
.wtx_total_byte
);
478 g_atm_priv_data
.prev_wtx_total_byte
= value
;
479 mib_aal5
.ifHCOutOctets_h
= g_atm_priv_data
.wtx_total_byte
.h
;
480 mib_aal5
.ifHCOutOctets_l
= g_atm_priv_data
.wtx_total_byte
.l
;
482 mib_aal5
.ifInUcastPkts
= g_atm_priv_data
.wrx_pdu
;
483 mib_aal5
.ifOutUcastPkts
= WAN_MIB_TABLE
->wtx_total_pdu
;
484 mib_aal5
.ifInErrors
= WAN_MIB_TABLE
->wrx_err_pdu
;
485 mib_aal5
.ifInDiscards
= WAN_MIB_TABLE
->wrx_dropdes_pdu
+ g_atm_priv_data
.wrx_drop_pdu
;
486 mib_aal5
.ifOutErros
= g_atm_priv_data
.wtx_err_pdu
;
487 mib_aal5
.ifOutDiscards
= g_atm_priv_data
.wtx_drop_pdu
;
489 ret
= sizeof(mib_aal5
) - copy_to_user(arg
, &mib_aal5
, sizeof(mib_aal5
));
492 case PPE_ATM_MIB_VCC
: /* VCC related MIB */
493 copy_from_user(&mib_vcc
, arg
, sizeof(mib_vcc
));
494 conn
= find_vpivci(mib_vcc
.vpi
, mib_vcc
.vci
);
497 mib_vcc
.mib_vcc
.aal5VccCrcErrors
= g_atm_priv_data
.conn
[conn
].aal5_vcc_crc_err
;
498 mib_vcc
.mib_vcc
.aal5VccOverSizedSDUs
= g_atm_priv_data
.conn
[conn
].aal5_vcc_oversize_sdu
;
499 mib_vcc
.mib_vcc
.aal5VccSarTimeOuts
= 0; /* no timer support */
500 ret
= sizeof(mib_vcc
) - copy_to_user(arg
, &mib_vcc
, sizeof(mib_vcc
));
513 static int ppe_open(struct atm_vcc
*vcc
)
516 short vpi
= vcc
->vpi
;
518 struct port
*port
= &g_atm_priv_data
.port
[(int)vcc
->dev
->dev_data
];
520 int f_enable_irq
= 0;
521 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
525 if ( vcc
->qos
.aal
!= ATM_AAL5
&& vcc
->qos
.aal
!= ATM_AAL0
)
526 return -EPROTONOSUPPORT
;
528 #if !defined(DISABLE_QOS_WORKAROUND) || !DISABLE_QOS_WORKAROUND
529 /* check bandwidth */
531 if (vcc
->qos
.txtp
.traffic_class
== ATM_CBR
&&
532 vcc
->qos
.txtp
.max_pcr
> (port
->tx_max_cell_rate
- port
->tx_current_cell_rate
))
534 printk("CBR set. %s, line %d returns EINVAL\n", __FUNCTION__
, __LINE__
);
538 if(vcc
->qos
.txtp
.traffic_class
== ATM_VBR_RT
&&
539 vcc
->qos
.txtp
.max_pcr
> (port
->tx_max_cell_rate
- port
->tx_current_cell_rate
))
541 printk("VBR RT set. %s, line %d returns EINVAL\n", __FUNCTION__
, __LINE__
);
546 if (vcc
->qos
.txtp
.traffic_class
== ATM_VBR_NRT
&&
547 vcc
->qos
.txtp
.scr
> (port
->tx_max_cell_rate
- port
->tx_current_cell_rate
))
549 printk("VBR NRT set. %s, line %d returns EINVAL\n", __FUNCTION__
, __LINE__
);
554 if (vcc
->qos
.txtp
.traffic_class
== ATM_UBR_PLUS
&&
555 vcc
->qos
.txtp
.min_pcr
> (port
->tx_max_cell_rate
- port
->tx_current_cell_rate
))
557 printk("UBR PLUS set. %s, line %d returns EINVAL\n", __FUNCTION__
, __LINE__
);
564 /* check existing vpi,vci */
565 conn
= find_vpivci(vpi
, vci
);
571 /* check whether it need to enable irq */
572 if ( g_atm_priv_data
.conn_table
== 0 )
575 /* allocate connection */
576 for ( conn
= 0; conn
< MAX_PVC_NUMBER
; conn
++ ) {
577 if ( test_and_set_bit(conn
, &g_atm_priv_data
.conn_table
) == 0 ) {
578 g_atm_priv_data
.conn
[conn
].vcc
= vcc
;
582 if ( conn
== MAX_PVC_NUMBER
)
584 printk("max_pvc_number reached\n");
589 /* reserve bandwidth */
590 switch ( vcc
->qos
.txtp
.traffic_class
) {
593 port
->tx_current_cell_rate
+= vcc
->qos
.txtp
.max_pcr
;
596 port
->tx_current_cell_rate
+= vcc
->qos
.txtp
.scr
;
599 port
->tx_current_cell_rate
+= vcc
->qos
.txtp
.min_pcr
;
604 set_qsb(vcc
, &vcc
->qos
, conn
);
606 /* update atm_vcc structure */
607 vcc
->itf
= (int)vcc
->dev
->dev_data
;
610 set_bit(ATM_VF_READY
, &vcc
->flags
);
614 ifx_atm_alloc_tx
= atm_alloc_tx
;
616 *MBOX_IGU1_ISRC
= (1 << RX_DMA_CH_AAL
) | (1 << RX_DMA_CH_OAM
);
617 *MBOX_IGU1_IER
= (1 << RX_DMA_CH_AAL
) | (1 << RX_DMA_CH_OAM
);
619 enable_irq(PPE_MAILBOX_IGU1_INT
);
623 WTX_QUEUE_CONFIG(conn
+ FIRST_QSB_QID
)->sbid
= (int)vcc
->dev
->dev_data
;
626 set_htu_entry(vpi
, vci
, conn
, vcc
->qos
.aal
== ATM_AAL5
? 1 : 0, 0);
628 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
629 // ReTX: occupy second QID
630 local_irq_save(sys_flag
);
631 if ( g_retx_htu
&& vcc
->qos
.aal
== ATM_AAL5
)
633 int retx_conn
= (conn
+ 8) % 16; // ReTX queue
635 if ( retx_conn
< MAX_PVC_NUMBER
&& test_and_set_bit(retx_conn
, &g_atm_priv_data
.conn_table
) == 0 ) {
636 g_atm_priv_data
.conn
[retx_conn
].vcc
= vcc
;
637 set_htu_entry(vpi
, vci
, retx_conn
, vcc
->qos
.aal
== ATM_AAL5
? 1 : 0, 1);
640 local_irq_restore(sys_flag
);
649 static void ppe_close(struct atm_vcc
*vcc
)
653 struct connection
*connection
;
654 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
661 /* get connection id */
662 conn
= find_vcc(vcc
);
664 err("can't find vcc");
667 connection
= &g_atm_priv_data
.conn
[conn
];
668 port
= &g_atm_priv_data
.port
[connection
->port
];
671 clear_htu_entry(conn
);
673 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
674 // ReTX: release second QID
675 local_irq_save(sys_flag
);
676 if ( g_retx_htu
&& vcc
->qos
.aal
== ATM_AAL5
)
678 int retx_conn
= (conn
+ 8) % 16; // ReTX queue
680 if ( retx_conn
< MAX_PVC_NUMBER
&& g_atm_priv_data
.conn
[retx_conn
].vcc
== vcc
) {
681 clear_htu_entry(retx_conn
);
682 g_atm_priv_data
.conn
[retx_conn
].vcc
= NULL
;
683 g_atm_priv_data
.conn
[retx_conn
].aal5_vcc_crc_err
= 0;
684 g_atm_priv_data
.conn
[retx_conn
].aal5_vcc_oversize_sdu
= 0;
685 clear_bit(retx_conn
, &g_atm_priv_data
.conn_table
);
688 local_irq_restore(sys_flag
);
691 /* release connection */
692 connection
->vcc
= NULL
;
693 connection
->aal5_vcc_crc_err
= 0;
694 connection
->aal5_vcc_oversize_sdu
= 0;
695 clear_bit(conn
, &g_atm_priv_data
.conn_table
);
698 if ( g_atm_priv_data
.conn_table
== 0 ) {
699 disable_irq(PPE_MAILBOX_IGU1_INT
);
700 ifx_atm_alloc_tx
= NULL
;
703 /* release bandwidth */
704 switch ( vcc
->qos
.txtp
.traffic_class
)
708 port
->tx_current_cell_rate
-= vcc
->qos
.txtp
.max_pcr
;
711 port
->tx_current_cell_rate
-= vcc
->qos
.txtp
.scr
;
714 port
->tx_current_cell_rate
-= vcc
->qos
.txtp
.min_pcr
;
722 static int ppe_send(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
727 struct tx_descriptor reg_desc
= {0};
729 if ( vcc
== NULL
|| skb
== NULL
)
734 atm_free_tx_skb_vcc(skb
, vcc
);
736 conn
= find_vcc(vcc
);
743 err("not in showtime");
748 if ( vcc
->qos
.aal
== ATM_AAL5
) {
751 struct tx_inband_header
*header
;
754 byteoff
= (unsigned int)skb
->data
& (DATA_BUFFER_ALIGNMENT
- 1);
756 if ( skb_headroom(skb
) < byteoff
+ TX_INBAND_HEADER_LENGTH
) {
757 struct sk_buff
*new_skb
;
759 new_skb
= alloc_skb_tx(datalen
);
760 if ( new_skb
== NULL
) {
761 err("ALLOC_SKB_TX_FAIL");
765 skb_put(new_skb
, datalen
);
766 memcpy(new_skb
->data
, skb
->data
, datalen
);
767 dev_kfree_skb_any(skb
);
769 byteoff
= (unsigned int)skb
->data
& (DATA_BUFFER_ALIGNMENT
- 1);
772 skb_push(skb
, byteoff
+ TX_INBAND_HEADER_LENGTH
);
774 header
= (struct tx_inband_header
*)skb
->data
;
776 /* setup inband trailer */
779 header
->pad
= aal5_fill_pattern
;
782 /* setup cell header */
783 header
->clp
= (vcc
->atm_options
& ATM_ATMOPT_CLP
) ? 1 : 0;
784 header
->pti
= ATM_PTI_US0
;
785 header
->vci
= vcc
->vci
;
786 header
->vpi
= vcc
->vpi
;
789 /* setup descriptor */
790 reg_desc
.dataptr
= (unsigned int)skb
->data
>> 2;
791 reg_desc
.datalen
= datalen
;
792 reg_desc
.byteoff
= byteoff
;
796 /* if data pointer is not aligned, allocate new sk_buff */
797 if ( ((unsigned int)skb
->data
& (DATA_BUFFER_ALIGNMENT
- 1)) != 0 ) {
798 struct sk_buff
*new_skb
;
800 err("skb->data not aligned");
802 new_skb
= alloc_skb_tx(skb
->len
);
803 if ( new_skb
== NULL
) {
804 err("ALLOC_SKB_TX_FAIL");
808 skb_put(new_skb
, skb
->len
);
809 memcpy(new_skb
->data
, skb
->data
, skb
->len
);
810 dev_kfree_skb_any(skb
);
814 reg_desc
.dataptr
= (unsigned int)skb
->data
>> 2;
815 reg_desc
.datalen
= skb
->len
;
816 reg_desc
.byteoff
= 0;
822 reg_desc
.sop
= reg_desc
.eop
= 1;
824 desc_base
= get_tx_desc(conn
);
825 if ( desc_base
< 0 ) {
826 err("ALLOC_TX_CONNECTION_FAIL");
832 atomic_inc(&vcc
->stats
->tx
);
833 if ( vcc
->qos
.aal
== ATM_AAL5
)
834 g_atm_priv_data
.wtx_pdu
++;
836 /* update descriptor send pointer */
837 if ( g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
] != NULL
)
838 dev_kfree_skb_any(g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
]);
839 g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
] = skb
;
841 /* write discriptor to memory and write back cache */
842 #ifdef CONFIG_DEBUG_SLAB
843 /* be sure that "redzone 1" is written back to memory */
844 dma_cache_wback((unsigned long)skb
->head
, 32);
846 dma_cache_wback((unsigned long)skb_shinfo(skb
), sizeof(struct skb_shared_info
));
847 dma_cache_wback((unsigned long)skb
->data
, skb
->len
);
848 g_atm_priv_data
.conn
[conn
].tx_desc
[desc_base
] = reg_desc
;
850 dump_skb(skb
, DUMP_SKB_LEN
, (char *)__func__
, 0, conn
, 1);
852 mailbox_signal(conn
, 1);
859 err("FIND_VCC_FAIL");
860 g_atm_priv_data
.wtx_err_pdu
++;
861 dev_kfree_skb_any(skb
);
865 if ( vcc
->qos
.aal
== ATM_AAL5
)
866 g_atm_priv_data
.wtx_drop_pdu
++;
868 atomic_inc(&vcc
->stats
->tx_err
);
869 dev_kfree_skb_any(skb
);
873 static int ppe_send_oam(struct atm_vcc
*vcc
, void *cell
, int flags
)
876 struct uni_cell_header
*uni_cell_header
= (struct uni_cell_header
*)cell
;
879 struct tx_descriptor reg_desc
= {0};
881 if ( ((uni_cell_header
->pti
== ATM_PTI_SEGF5
|| uni_cell_header
->pti
== ATM_PTI_E2EF5
)
882 && find_vpivci(uni_cell_header
->vpi
, uni_cell_header
->vci
) < 0)
883 || ((uni_cell_header
->vci
== 0x03 || uni_cell_header
->vci
== 0x04)
884 && find_vpi(uni_cell_header
->vpi
) < 0) )
888 err("not in showtime");
892 conn
= find_vcc(vcc
);
894 err("FIND_VCC_FAIL");
898 skb
= alloc_skb_tx(CELL_SIZE
);
900 err("ALLOC_SKB_TX_FAIL");
903 memcpy(skb
->data
, cell
, CELL_SIZE
);
905 reg_desc
.dataptr
= (unsigned int)skb
->data
>> 2;
906 reg_desc
.datalen
= CELL_SIZE
;
907 reg_desc
.byteoff
= 0;
912 reg_desc
.sop
= reg_desc
.eop
= 1;
914 desc_base
= get_tx_desc(conn
);
915 if ( desc_base
< 0 ) {
916 dev_kfree_skb_any(skb
);
917 err("ALLOC_TX_CONNECTION_FAIL");
922 atomic_inc(&vcc
->stats
->tx
);
924 /* update descriptor send pointer */
925 if ( g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
] != NULL
)
926 dev_kfree_skb_any(g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
]);
927 g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
] = skb
;
929 /* write discriptor to memory and write back cache */
930 g_atm_priv_data
.conn
[conn
].tx_desc
[desc_base
] = reg_desc
;
931 dma_cache_wback((unsigned long)skb
->data
, CELL_SIZE
);
933 dump_skb(skb
, DUMP_SKB_LEN
, (char *)__func__
, 0, conn
, 1);
935 if ( vcc
->qos
.aal
== ATM_AAL5
&& (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_MAC_SWAP
) ) {
936 skb_swap(skb
, reg_desc
.byteoff
);
939 mailbox_signal(conn
, 1);
946 static int ppe_change_qos(struct atm_vcc
*vcc
, struct atm_qos
*qos
, int flags
)
950 if ( vcc
== NULL
|| qos
== NULL
)
953 conn
= find_vcc(vcc
);
957 set_qsb(vcc
, qos
, conn
);
962 static INLINE
void adsl_led_flash(void)
965 #if defined(ENABLE_LED_FRAMEWORK) && ENABLE_LED_FRAMEWORK
966 if ( g_data_led_trigger
!= NULL
)
967 ifx_led_trigger_activate(g_data_led_trigger
);
969 if (!IS_ERR(&ifx_mei_atm_led_blink
) && &ifx_mei_atm_led_blink
)
970 ifx_mei_atm_led_blink();
977 * Add a 32-bit value to 64-bit value, and put result in a 64-bit variable.
979 * opt1 --- ppe_u64_t, first operand, a 64-bit unsigned integer value
980 * opt2 --- unsigned int, second operand, a 32-bit unsigned integer value
981 * ret --- ppe_u64_t, pointer to a variable to hold result
985 static INLINE
void u64_add_u32(ppe_u64_t opt1
, unsigned int opt2
, ppe_u64_t
*ret
)
987 ret
->l
= opt1
.l
+ opt2
;
988 if ( ret
->l
< opt1
.l
|| ret
->l
< opt2
)
992 static INLINE
struct sk_buff
* alloc_skb_rx(void)
996 skb
= dev_alloc_skb(RX_DMA_CH_AAL_BUF_SIZE
+ DATA_BUFFER_ALIGNMENT
);
998 /* must be burst length alignment */
999 if ( ((unsigned int)skb
->data
& (DATA_BUFFER_ALIGNMENT
- 1)) != 0 )
1000 skb_reserve(skb
, ~((unsigned int)skb
->data
+ (DATA_BUFFER_ALIGNMENT
- 1)) & (DATA_BUFFER_ALIGNMENT
- 1));
1001 /* pub skb in reserved area "skb->data - 4" */
1002 *((struct sk_buff
**)skb
->data
- 1) = skb
;
1003 /* write back and invalidate cache */
1004 dma_cache_wback_inv((unsigned long)skb
->data
- sizeof(skb
), sizeof(skb
));
1005 /* invalidate cache */
1006 dma_cache_inv((unsigned long)skb
->data
, (unsigned int)skb
->end
- (unsigned int)skb
->data
);
1012 static INLINE
struct sk_buff
* alloc_skb_tx(unsigned int size
)
1014 struct sk_buff
*skb
;
1016 /* allocate memory including header and padding */
1017 size
+= TX_INBAND_HEADER_LENGTH
+ MAX_TX_PACKET_ALIGN_BYTES
+ MAX_TX_PACKET_PADDING_BYTES
;
1018 size
&= ~(DATA_BUFFER_ALIGNMENT
- 1);
1019 skb
= dev_alloc_skb(size
+ DATA_BUFFER_ALIGNMENT
);
1020 /* must be burst length alignment */
1022 skb_reserve(skb
, (~((unsigned int)skb
->data
+ (DATA_BUFFER_ALIGNMENT
- 1)) & (DATA_BUFFER_ALIGNMENT
- 1)) + TX_INBAND_HEADER_LENGTH
);
1026 struct sk_buff
* atm_alloc_tx(struct atm_vcc
*vcc
, unsigned int size
)
1029 struct sk_buff
*skb
;
1031 /* oversize packet */
1032 if ( size
> aal5s_max_packet_size
) {
1033 err("atm_alloc_tx: oversize packet");
1036 /* send buffer overflow */
1037 if ( atomic_read(&sk_atm(vcc
)->sk_wmem_alloc
) && !atm_may_send(vcc
, size
) ) {
1038 err("atm_alloc_tx: send buffer overflow");
1041 conn
= find_vcc(vcc
);
1043 err("atm_alloc_tx: unknown VCC");
1047 skb
= dev_alloc_skb(size
);
1048 if ( skb
== NULL
) {
1049 err("atm_alloc_tx: sk buffer is used up");
1053 atomic_add(skb
->truesize
, &sk_atm(vcc
)->sk_wmem_alloc
);
1058 static INLINE
void atm_free_tx_skb_vcc(struct sk_buff
*skb
, struct atm_vcc
*vcc
)
1060 if ( vcc
->pop
!= NULL
)
1063 dev_kfree_skb_any(skb
);
1066 static INLINE
struct sk_buff
*get_skb_rx_pointer(unsigned int dataptr
)
1068 unsigned int skb_dataptr
;
1069 struct sk_buff
*skb
;
1071 skb_dataptr
= ((dataptr
- 1) << 2) | KSEG1
;
1072 skb
= *(struct sk_buff
**)skb_dataptr
;
1074 ASSERT((unsigned int)skb
>= KSEG0
, "invalid skb - skb = %#08x, dataptr = %#08x", (unsigned int)skb
, dataptr
);
1075 ASSERT(((unsigned int)skb
->data
| KSEG1
) == ((dataptr
<< 2) | KSEG1
), "invalid skb - skb = %#08x, skb->data = %#08x, dataptr = %#08x", (unsigned int)skb
, (unsigned int)skb
->data
, dataptr
);
1080 static INLINE
int get_tx_desc(unsigned int conn
)
1083 struct connection
*p_conn
= &g_atm_priv_data
.conn
[conn
];
1085 if ( p_conn
->tx_desc
[p_conn
->tx_desc_pos
].own
== 0 ) {
1086 desc_base
= p_conn
->tx_desc_pos
;
1087 if ( ++(p_conn
->tx_desc_pos
) == dma_tx_descriptor_length
)
1088 p_conn
->tx_desc_pos
= 0;
1094 static INLINE
void mailbox_oam_rx_handler(void)
1096 unsigned int vlddes
= WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_OAM
)->vlddes
;
1097 struct rx_descriptor reg_desc
;
1098 struct uni_cell_header
*header
;
1100 struct atm_vcc
*vcc
;
1103 for ( i
= 0; i
< vlddes
; i
++ ) {
1105 reg_desc
= g_atm_priv_data
.oam_desc
[g_atm_priv_data
.oam_desc_pos
];
1106 } while ( reg_desc
.own
|| !reg_desc
.c
); // keep test OWN and C bit until data is ready
1108 header
= (struct uni_cell_header
*)&g_atm_priv_data
.oam_buf
[g_atm_priv_data
.oam_desc_pos
* RX_DMA_CH_OAM_BUF_SIZE
];
1110 if ( header
->pti
== ATM_PTI_SEGF5
|| header
->pti
== ATM_PTI_E2EF5
)
1111 conn
= find_vpivci(header
->vpi
, header
->vci
);
1112 else if ( header
->vci
== 0x03 || header
->vci
== 0x04 )
1113 conn
= find_vpi(header
->vpi
);
1117 if ( conn
>= 0 && g_atm_priv_data
.conn
[conn
].vcc
!= NULL
) {
1118 vcc
= g_atm_priv_data
.conn
[conn
].vcc
;
1120 if ( vcc
->push_oam
!= NULL
)
1121 vcc
->push_oam(vcc
, header
);
1123 ifx_push_oam((unsigned char *)header
);
1127 reg_desc
.byteoff
= 0;
1128 reg_desc
.datalen
= RX_DMA_CH_OAM_BUF_SIZE
;
1132 g_atm_priv_data
.oam_desc
[g_atm_priv_data
.oam_desc_pos
] = reg_desc
;
1133 if ( ++g_atm_priv_data
.oam_desc_pos
== RX_DMA_CH_OAM_DESC_LEN
)
1134 g_atm_priv_data
.oam_desc_pos
= 0;
1136 mailbox_signal(RX_DMA_CH_OAM
, 0);
1140 static INLINE
void mailbox_aal_rx_handler(void)
1142 unsigned int vlddes
= WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_AAL
)->vlddes
;
1143 struct rx_descriptor reg_desc
;
1145 struct atm_vcc
*vcc
;
1146 struct sk_buff
*skb
, *new_skb
;
1147 struct rx_inband_trailer
*trailer
;
1150 for ( i
= 0; i
< vlddes
; i
++ ) {
1152 reg_desc
= g_atm_priv_data
.aal_desc
[g_atm_priv_data
.aal_desc_pos
];
1153 } while ( reg_desc
.own
|| !reg_desc
.c
); // keep test OWN and C bit until data is ready
1157 if ( g_atm_priv_data
.conn
[conn
].vcc
!= NULL
) {
1158 vcc
= g_atm_priv_data
.conn
[conn
].vcc
;
1160 skb
= get_skb_rx_pointer(reg_desc
.dataptr
);
1162 if ( reg_desc
.err
) {
1163 if ( vcc
->qos
.aal
== ATM_AAL5
) {
1164 trailer
= (struct rx_inband_trailer
*)((unsigned int)skb
->data
+ ((reg_desc
.byteoff
+ reg_desc
.datalen
+ MAX_RX_PACKET_PADDING_BYTES
) & ~MAX_RX_PACKET_PADDING_BYTES
));
1165 if ( trailer
->stw_crc
)
1166 g_atm_priv_data
.conn
[conn
].aal5_vcc_crc_err
++;
1167 if ( trailer
->stw_ovz
)
1168 g_atm_priv_data
.conn
[conn
].aal5_vcc_oversize_sdu
++;
1169 g_atm_priv_data
.wrx_drop_pdu
++;
1172 atomic_inc(&vcc
->stats
->rx_drop
);
1173 atomic_inc(&vcc
->stats
->rx_err
);
1176 else if ( atm_charge(vcc
, skb
->truesize
) ) {
1177 new_skb
= alloc_skb_rx();
1178 if ( new_skb
!= NULL
) {
1179 skb_reserve(skb
, reg_desc
.byteoff
);
1180 skb_put(skb
, reg_desc
.datalen
);
1181 ATM_SKB(skb
)->vcc
= vcc
;
1183 dump_skb(skb
, DUMP_SKB_LEN
, (char *)__func__
, 0, conn
, 0);
1185 vcc
->push(vcc
, skb
);
1187 if ( vcc
->qos
.aal
== ATM_AAL5
)
1188 g_atm_priv_data
.wrx_pdu
++;
1190 atomic_inc(&vcc
->stats
->rx
);
1193 reg_desc
.dataptr
= (unsigned int)new_skb
->data
>> 2;
1196 atm_return(vcc
, skb
->truesize
);
1197 if ( vcc
->qos
.aal
== ATM_AAL5
)
1198 g_atm_priv_data
.wrx_drop_pdu
++;
1200 atomic_inc(&vcc
->stats
->rx_drop
);
1204 if ( vcc
->qos
.aal
== ATM_AAL5
)
1205 g_atm_priv_data
.wrx_drop_pdu
++;
1207 atomic_inc(&vcc
->stats
->rx_drop
);
1211 g_atm_priv_data
.wrx_drop_pdu
++;
1214 reg_desc
.byteoff
= 0;
1215 reg_desc
.datalen
= RX_DMA_CH_AAL_BUF_SIZE
;
1219 g_atm_priv_data
.aal_desc
[g_atm_priv_data
.aal_desc_pos
] = reg_desc
;
1220 if ( ++g_atm_priv_data
.aal_desc_pos
== dma_rx_descriptor_length
)
1221 g_atm_priv_data
.aal_desc_pos
= 0;
1223 mailbox_signal(RX_DMA_CH_AAL
, 0);
1227 #if defined(ENABLE_TASKLET) && ENABLE_TASKLET
1228 static void do_ppe_tasklet(unsigned long arg
)
1230 *MBOX_IGU1_ISRC
= *MBOX_IGU1_ISR
;
1231 mailbox_oam_rx_handler();
1232 mailbox_aal_rx_handler();
1233 if ( (*MBOX_IGU1_ISR
& ((1 << RX_DMA_CH_AAL
) | (1 << RX_DMA_CH_OAM
))) != 0 )
1234 tasklet_schedule(&g_dma_tasklet
);
1236 enable_irq(PPE_MAILBOX_IGU1_INT
);
1240 static irqreturn_t
mailbox_irq_handler(int irq
, void *dev_id
)
1242 if ( !*MBOX_IGU1_ISR
)
1245 #if defined(ENABLE_TASKLET) && ENABLE_TASKLET
1246 disable_irq(PPE_MAILBOX_IGU1_INT
);
1247 tasklet_schedule(&g_dma_tasklet
);
1249 *MBOX_IGU1_ISRC
= *MBOX_IGU1_ISR
;
1250 mailbox_oam_rx_handler();
1251 mailbox_aal_rx_handler();
1257 static INLINE
void mailbox_signal(unsigned int queue
, int is_tx
)
1262 while ( MBOX_IGU3_ISR_ISR(queue
+ FIRST_QSB_QID
+ 16) && count
)
1264 *MBOX_IGU3_ISRS
= MBOX_IGU3_ISRS_SET(queue
+ FIRST_QSB_QID
+ 16);
1267 while ( MBOX_IGU3_ISR_ISR(queue
) && count
)
1269 *MBOX_IGU3_ISRS
= MBOX_IGU3_ISRS_SET(queue
);
1271 ASSERT(count
!= 0, "MBOX_IGU3_ISR = 0x%08x", ltq_r32(MBOX_IGU3_ISR
));
1274 static void set_qsb(struct atm_vcc
*vcc
, struct atm_qos
*qos
, unsigned int queue
)
1276 struct clk
*clk
= clk_get(0, "fpi");
1277 unsigned int qsb_clk
= clk_get_rate(clk
);
1278 unsigned int qsb_qid
= queue
+ FIRST_QSB_QID
;
1279 union qsb_queue_parameter_table qsb_queue_parameter_table
= {{0}};
1280 union qsb_queue_vbr_parameter_table qsb_queue_vbr_parameter_table
= {{0}};
1283 #if defined(DEBUG_QOS) && DEBUG_QOS
1284 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) ) {
1285 static char *str_traffic_class
[9] = {
1296 printk(KERN_INFO
"QoS Parameters:\n");
1297 printk(KERN_INFO
"\tAAL : %d\n", qos
->aal
);
1298 printk(KERN_INFO
"\tTX Traffic Class: %s\n", str_traffic_class
[qos
->txtp
.traffic_class
]);
1299 printk(KERN_INFO
"\tTX Max PCR : %d\n", qos
->txtp
.max_pcr
);
1300 printk(KERN_INFO
"\tTX Min PCR : %d\n", qos
->txtp
.min_pcr
);
1301 printk(KERN_INFO
"\tTX PCR : %d\n", qos
->txtp
.pcr
);
1302 printk(KERN_INFO
"\tTX Max CDV : %d\n", qos
->txtp
.max_cdv
);
1303 printk(KERN_INFO
"\tTX Max SDU : %d\n", qos
->txtp
.max_sdu
);
1304 printk(KERN_INFO
"\tTX SCR : %d\n", qos
->txtp
.scr
);
1305 printk(KERN_INFO
"\tTX MBS : %d\n", qos
->txtp
.mbs
);
1306 printk(KERN_INFO
"\tTX CDV : %d\n", qos
->txtp
.cdv
);
1307 printk(KERN_INFO
"\tRX Traffic Class: %s\n", str_traffic_class
[qos
->rxtp
.traffic_class
]);
1308 printk(KERN_INFO
"\tRX Max PCR : %d\n", qos
->rxtp
.max_pcr
);
1309 printk(KERN_INFO
"\tRX Min PCR : %d\n", qos
->rxtp
.min_pcr
);
1310 printk(KERN_INFO
"\tRX PCR : %d\n", qos
->rxtp
.pcr
);
1311 printk(KERN_INFO
"\tRX Max CDV : %d\n", qos
->rxtp
.max_cdv
);
1312 printk(KERN_INFO
"\tRX Max SDU : %d\n", qos
->rxtp
.max_sdu
);
1313 printk(KERN_INFO
"\tRX SCR : %d\n", qos
->rxtp
.scr
);
1314 printk(KERN_INFO
"\tRX MBS : %d\n", qos
->rxtp
.mbs
);
1315 printk(KERN_INFO
"\tRX CDV : %d\n", qos
->rxtp
.cdv
);
1317 #endif // defined(DEBUG_QOS) && DEBUG_QOS
1320 * Peak Cell Rate (PCR) Limiter
1322 if ( qos
->txtp
.max_pcr
== 0 )
1323 qsb_queue_parameter_table
.bit
.tp
= 0; /* disable PCR limiter */
1325 /* peak cell rate would be slightly lower than requested [maximum_rate / pcr = (qsb_clock / 8) * (time_step / 4) / pcr] */
1326 tmp
= ((qsb_clk
* qsb_tstep
) >> 5) / qos
->txtp
.max_pcr
+ 1;
1327 /* check if overflow takes place */
1328 qsb_queue_parameter_table
.bit
.tp
= tmp
> QSB_TP_TS_MAX
? QSB_TP_TS_MAX
: tmp
;
1331 // A funny issue. Create two PVCs, one UBR and one UBR with max_pcr.
1332 // Send packets to these two PVCs at same time, it trigger strange behavior.
1333 // In A1, RAM from 0x80000000 to 0x0x8007FFFF was corrupted with fixed pattern 0x00000000 0x40000000.
1334 // In A4, PPE firmware keep emiting unknown cell and do not respond to driver.
1335 // To work around, create UBR always with max_pcr.
1336 // If user want to create UBR without max_pcr, we give a default one larger than line-rate.
1337 if ( qos
->txtp
.traffic_class
== ATM_UBR
&& qsb_queue_parameter_table
.bit
.tp
== 0 ) {
1338 int port
= g_atm_priv_data
.conn
[queue
].port
;
1339 unsigned int max_pcr
= g_atm_priv_data
.port
[port
].tx_max_cell_rate
+ 1000;
1341 tmp
= ((qsb_clk
* qsb_tstep
) >> 5) / max_pcr
+ 1;
1342 if ( tmp
> QSB_TP_TS_MAX
)
1343 tmp
= QSB_TP_TS_MAX
;
1346 qsb_queue_parameter_table
.bit
.tp
= tmp
;
1350 * Weighted Fair Queueing Factor (WFQF)
1352 switch ( qos
->txtp
.traffic_class
) {
1355 /* real time queue gets weighted fair queueing bypass */
1356 qsb_queue_parameter_table
.bit
.wfqf
= 0;
1360 /* WFQF calculation here is based on virtual cell rates, to reduce granularity for high rates */
1361 /* WFQF is maximum cell rate / garenteed cell rate */
1362 /* wfqf = qsb_minimum_cell_rate * QSB_WFQ_NONUBR_MAX / requested_minimum_peak_cell_rate */
1363 if ( qos
->txtp
.min_pcr
== 0 )
1364 qsb_queue_parameter_table
.bit
.wfqf
= QSB_WFQ_NONUBR_MAX
;
1367 tmp
= QSB_GCR_MIN
* QSB_WFQ_NONUBR_MAX
/ qos
->txtp
.min_pcr
;
1369 qsb_queue_parameter_table
.bit
.wfqf
= 1;
1370 else if ( tmp
> QSB_WFQ_NONUBR_MAX
)
1371 qsb_queue_parameter_table
.bit
.wfqf
= QSB_WFQ_NONUBR_MAX
;
1373 qsb_queue_parameter_table
.bit
.wfqf
= tmp
;
1378 qsb_queue_parameter_table
.bit
.wfqf
= QSB_WFQ_UBR_BYPASS
;
1382 * Sustained Cell Rate (SCR) Leaky Bucket Shaper VBR.0/VBR.1
1384 if ( qos
->txtp
.traffic_class
== ATM_VBR_RT
|| qos
->txtp
.traffic_class
== ATM_VBR_NRT
) {
1385 if ( qos
->txtp
.scr
== 0 ) {
1386 /* disable shaper */
1387 qsb_queue_vbr_parameter_table
.bit
.taus
= 0;
1388 qsb_queue_vbr_parameter_table
.bit
.ts
= 0;
1391 /* Cell Loss Priority (CLP) */
1392 if ( (vcc
->atm_options
& ATM_ATMOPT_CLP
) )
1394 qsb_queue_parameter_table
.bit
.vbr
= 1;
1397 qsb_queue_parameter_table
.bit
.vbr
= 0;
1398 /* Rate Shaper Parameter (TS) and Burst Tolerance Parameter for SCR (tauS) */
1399 tmp
= ((qsb_clk
* qsb_tstep
) >> 5) / qos
->txtp
.scr
+ 1;
1400 qsb_queue_vbr_parameter_table
.bit
.ts
= tmp
> QSB_TP_TS_MAX
? QSB_TP_TS_MAX
: tmp
;
1401 tmp
= (qos
->txtp
.mbs
- 1) * (qsb_queue_vbr_parameter_table
.bit
.ts
- qsb_queue_parameter_table
.bit
.tp
) / 64;
1403 qsb_queue_vbr_parameter_table
.bit
.taus
= 1;
1404 else if ( tmp
> QSB_TAUS_MAX
)
1405 qsb_queue_vbr_parameter_table
.bit
.taus
= QSB_TAUS_MAX
;
1407 qsb_queue_vbr_parameter_table
.bit
.taus
= tmp
;
1411 qsb_queue_vbr_parameter_table
.bit
.taus
= 0;
1412 qsb_queue_vbr_parameter_table
.bit
.ts
= 0;
1415 /* Queue Parameter Table (QPT) */
1416 *QSB_RTM
= QSB_RTM_DM_SET(QSB_QPT_SET_MASK
);
1417 *QSB_RTD
= QSB_RTD_TTV_SET(qsb_queue_parameter_table
.dword
);
1418 *QSB_RAMAC
= QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE
) | QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_QPT
) | QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW
) | QSB_RAMAC_TESEL_SET(qsb_qid
);
1419 #if defined(DEBUG_QOS) && DEBUG_QOS
1420 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) )
1421 printk("QPT: QSB_RTM (%08X) = 0x%08X, QSB_RTD (%08X) = 0x%08X, QSB_RAMAC (%08X) = 0x%08X\n", (unsigned int)QSB_RTM
, *QSB_RTM
, (unsigned int)QSB_RTD
, *QSB_RTD
, (unsigned int)QSB_RAMAC
, *QSB_RAMAC
);
1423 /* Queue VBR Paramter Table (QVPT) */
1424 *QSB_RTM
= QSB_RTM_DM_SET(QSB_QVPT_SET_MASK
);
1425 *QSB_RTD
= QSB_RTD_TTV_SET(qsb_queue_vbr_parameter_table
.dword
);
1426 *QSB_RAMAC
= QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE
) | QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_VBR
) | QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW
) | QSB_RAMAC_TESEL_SET(qsb_qid
);
1427 #if defined(DEBUG_QOS) && DEBUG_QOS
1428 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) )
1429 printk("QVPT: QSB_RTM (%08X) = 0x%08X, QSB_RTD (%08X) = 0x%08X, QSB_RAMAC (%08X) = 0x%08X\n", (unsigned int)QSB_RTM
, *QSB_RTM
, (unsigned int)QSB_RTD
, *QSB_RTD
, (unsigned int)QSB_RAMAC
, *QSB_RAMAC
);
1432 #if defined(DEBUG_QOS) && DEBUG_QOS
1433 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) ) {
1434 printk("set_qsb\n");
1435 printk(" qsb_clk = %lu\n", (unsigned long)qsb_clk
);
1436 printk(" qsb_queue_parameter_table.bit.tp = %d\n", (int)qsb_queue_parameter_table
.bit
.tp
);
1437 printk(" qsb_queue_parameter_table.bit.wfqf = %d (0x%08X)\n", (int)qsb_queue_parameter_table
.bit
.wfqf
, (int)qsb_queue_parameter_table
.bit
.wfqf
);
1438 printk(" qsb_queue_parameter_table.bit.vbr = %d\n", (int)qsb_queue_parameter_table
.bit
.vbr
);
1439 printk(" qsb_queue_parameter_table.dword = 0x%08X\n", (int)qsb_queue_parameter_table
.dword
);
1440 printk(" qsb_queue_vbr_parameter_table.bit.ts = %d\n", (int)qsb_queue_vbr_parameter_table
.bit
.ts
);
1441 printk(" qsb_queue_vbr_parameter_table.bit.taus = %d\n", (int)qsb_queue_vbr_parameter_table
.bit
.taus
);
1442 printk(" qsb_queue_vbr_parameter_table.dword = 0x%08X\n", (int)qsb_queue_vbr_parameter_table
.dword
);
1447 static void qsb_global_set(void)
1449 struct clk
*clk
= clk_get(0, "fpi");
1450 unsigned int qsb_clk
= clk_get_rate(clk
);
1452 unsigned int tmp1
, tmp2
, tmp3
;
1454 *QSB_ICDV
= QSB_ICDV_TAU_SET(qsb_tau
);
1455 *QSB_SBL
= QSB_SBL_SBL_SET(qsb_srvm
);
1456 *QSB_CFG
= QSB_CFG_TSTEPC_SET(qsb_tstep
>> 1);
1457 #if defined(DEBUG_QOS) && DEBUG_QOS
1458 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) ) {
1459 printk("qsb_clk = %u\n", qsb_clk
);
1460 printk("QSB_ICDV (%08X) = %d (%d), QSB_SBL (%08X) = %d (%d), QSB_CFG (%08X) = %d (%d)\n", (unsigned int)QSB_ICDV
, *QSB_ICDV
, QSB_ICDV_TAU_SET(qsb_tau
), (unsigned int)QSB_SBL
, *QSB_SBL
, QSB_SBL_SBL_SET(qsb_srvm
), (unsigned int)QSB_CFG
, *QSB_CFG
, QSB_CFG_TSTEPC_SET(qsb_tstep
>> 1));
1465 * set SCT and SPT per port
1467 for ( i
= 0; i
< ATM_PORT_NUMBER
; i
++ ) {
1468 if ( g_atm_priv_data
.port
[i
].tx_max_cell_rate
!= 0 ) {
1469 tmp1
= ((qsb_clk
* qsb_tstep
) >> 1) / g_atm_priv_data
.port
[i
].tx_max_cell_rate
;
1470 tmp2
= tmp1
>> 6; /* integer value of Tsb */
1471 tmp3
= (tmp1
& ((1 << 6) - 1)) + 1; /* fractional part of Tsb */
1472 /* carry over to integer part (?) */
1473 if ( tmp3
== (1 << 6) )
1481 /* 2. write value to data transfer register */
1482 /* 3. start the tranfer */
1483 /* SCT (FracRate) */
1484 *QSB_RTM
= QSB_RTM_DM_SET(QSB_SET_SCT_MASK
);
1485 *QSB_RTD
= QSB_RTD_TTV_SET(tmp3
);
1486 *QSB_RAMAC
= QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE
) | QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_SCT
) | QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW
) | QSB_RAMAC_TESEL_SET(i
& 0x01);
1487 #if defined(DEBUG_QOS) && DEBUG_QOS
1488 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) )
1489 printk("SCT: QSB_RTM (%08X) = 0x%08X, QSB_RTD (%08X) = 0x%08X, QSB_RAMAC (%08X) = 0x%08X\n", (unsigned int)QSB_RTM
, *QSB_RTM
, (unsigned int)QSB_RTD
, *QSB_RTD
, (unsigned int)QSB_RAMAC
, *QSB_RAMAC
);
1491 /* SPT (SBV + PN + IntRage) */
1492 *QSB_RTM
= QSB_RTM_DM_SET(QSB_SET_SPT_MASK
);
1493 *QSB_RTD
= QSB_RTD_TTV_SET(QSB_SPT_SBV_VALID
| QSB_SPT_PN_SET(i
& 0x01) | QSB_SPT_INTRATE_SET(tmp2
));
1494 *QSB_RAMAC
= QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE
) | QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_SPT
) | QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW
) | QSB_RAMAC_TESEL_SET(i
& 0x01);
1495 #if defined(DEBUG_QOS) && DEBUG_QOS
1496 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) )
1497 printk("SPT: QSB_RTM (%08X) = 0x%08X, QSB_RTD (%08X) = 0x%08X, QSB_RAMAC (%08X) = 0x%08X\n", (unsigned int)QSB_RTM
, *QSB_RTM
, (unsigned int)QSB_RTD
, *QSB_RTD
, (unsigned int)QSB_RAMAC
, *QSB_RAMAC
);
1503 static INLINE
void set_htu_entry(unsigned int vpi
, unsigned int vci
, unsigned int queue
, int aal5
, int is_retx
)
1505 struct htu_entry htu_entry
= { res1
: 0x00,
1506 clp
: is_retx
? 0x01 : 0x00,
1507 pid
: g_atm_priv_data
.conn
[queue
].port
& 0x01,
1513 struct htu_mask htu_mask
= { set
: 0x01,
1514 #if !defined(ENABLE_ATM_RETX) || !ENABLE_ATM_RETX
1518 clp
: g_retx_htu
? 0x00 : 0x01,
1519 pid_mask
: RETX_MODE_CFG
->retx_en
? 0x03 : 0x02,
1522 #if !defined(ENABLE_ATM_RETX) || !ENABLE_ATM_RETX
1525 vci_mask
: RETX_MODE_CFG
->retx_en
? 0xFF00 : 0x0000,
1527 pti_mask
: 0x03, // 0xx, user data
1530 struct htu_result htu_result
= {res1
: 0x00,
1533 type
: aal5
? 0x00 : 0x01,
1538 *HTU_RESULT(queue
+ OAM_HTU_ENTRY_NUMBER
) = htu_result
;
1539 *HTU_MASK(queue
+ OAM_HTU_ENTRY_NUMBER
) = htu_mask
;
1540 *HTU_ENTRY(queue
+ OAM_HTU_ENTRY_NUMBER
) = htu_entry
;
1543 static INLINE
void clear_htu_entry(unsigned int queue
)
1545 HTU_ENTRY(queue
+ OAM_HTU_ENTRY_NUMBER
)->vld
= 0;
1548 static void validate_oam_htu_entry(void)
1550 HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY
)->vld
= 1;
1551 HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY
)->vld
= 1;
1552 HTU_ENTRY(OAM_F5_HTU_ENTRY
)->vld
= 1;
1553 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
1554 HTU_ENTRY(OAM_ARQ_HTU_ENTRY
)->vld
= 1;
1558 static void invalidate_oam_htu_entry(void)
1560 HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY
)->vld
= 0;
1561 HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY
)->vld
= 0;
1562 HTU_ENTRY(OAM_F5_HTU_ENTRY
)->vld
= 0;
1563 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
1564 HTU_ENTRY(OAM_ARQ_HTU_ENTRY
)->vld
= 0;
1568 static INLINE
int find_vpi(unsigned int vpi
)
1573 for ( i
= 0, bit
= 1; i
< MAX_PVC_NUMBER
; i
++, bit
<<= 1 ) {
1574 if ( (g_atm_priv_data
.conn_table
& bit
) != 0
1575 && g_atm_priv_data
.conn
[i
].vcc
!= NULL
1576 && vpi
== g_atm_priv_data
.conn
[i
].vcc
->vpi
)
1583 static INLINE
int find_vpivci(unsigned int vpi
, unsigned int vci
)
1588 for ( i
= 0, bit
= 1; i
< MAX_PVC_NUMBER
; i
++, bit
<<= 1 ) {
1589 if ( (g_atm_priv_data
.conn_table
& bit
) != 0
1590 && g_atm_priv_data
.conn
[i
].vcc
!= NULL
1591 && vpi
== g_atm_priv_data
.conn
[i
].vcc
->vpi
1592 && vci
== g_atm_priv_data
.conn
[i
].vcc
->vci
)
1599 static INLINE
int find_vcc(struct atm_vcc
*vcc
)
1604 for ( i
= 0, bit
= 1; i
< MAX_PVC_NUMBER
; i
++, bit
<<= 1 ) {
1605 if ( (g_atm_priv_data
.conn_table
& bit
) != 0
1606 && g_atm_priv_data
.conn
[i
].vcc
== vcc
)
1613 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
1615 static void retx_polling_func(unsigned long arg
)
1618 volatile struct dsl_param
*p_dsl_param
;
1623 local_irq_save(sys_flag
);
1624 if ( g_retx_playout_buffer
== 0 && g_xdata_addr
!= NULL
&& (((volatile struct dsl_param
*)g_xdata_addr
)->RetxEnable
|| ((volatile struct dsl_param
*)g_xdata_addr
)->ServiceSpecificReTx
) ) {
1625 local_irq_restore(sys_flag
);
1626 g_retx_playout_buffer
= __get_free_pages(GFP_KERNEL
, RETX_PLAYOUT_BUFFER_ORDER
);
1627 if ( g_retx_playout_buffer
== 0 )
1628 panic("no memory for g_retx_playout_buffer\n");
1629 memset((void *)g_retx_playout_buffer
, 0, RETX_PLAYOUT_BUFFER_SIZE
);
1630 dma_cache_inv(g_retx_playout_buffer
, RETX_PLAYOUT_BUFFER_SIZE
);
1633 local_irq_restore(sys_flag
);
1636 local_irq_save(sys_flag
);
1637 if ( g_xdata_addr
!= NULL
) {
1638 p_dsl_param
= (volatile struct dsl_param
*)g_xdata_addr
;
1639 g_retx_polling_cnt
+= RETX_POLLING_INTERVAL
;
1641 if ( p_dsl_param
->update_flag
) {
1642 do_gettimeofday(&g_retx_polling_start
);
1644 g_dsl_param
= *p_dsl_param
;
1646 // we always enable retx (just for test purpose)
1647 //g_dsl_param.RetxEnable = 1;
1648 //RETX_TSYNC_CFG->fw_alpha = 0;
1650 if ( g_dsl_param
.RetxEnable
|| g_dsl_param
.ServiceSpecificReTx
) {
1652 // MIB counter updated for each polling
1653 p_dsl_param
->RxDtuCorruptedCNT
= *RxDTUCorruptedCNT
;
1654 p_dsl_param
->RxRetxDtuUnCorrectedCNT
= *RxRetxDTUUncorrectedCNT
;
1655 p_dsl_param
->RxLastEFB
= *RxLastEFBCNT
;
1656 p_dsl_param
->RxDtuCorrectedCNT
= *RxDTUCorrectedCNT
;
1658 // for RETX paramters, we check only once for every second
1659 if ( g_retx_polling_cnt
< HZ
)
1660 goto _clear_update_flag
;
1662 g_retx_polling_cnt
-= HZ
;
1664 if ( g_dsl_param
.ServiceSpecificReTx
&& g_dsl_param
.ReTxPVC
== 0 )
1669 // default fw_alpha equals to default hardware alpha
1670 RETX_TSYNC_CFG
->fw_alpha
= 0;
1672 RETX_TD_CFG
->td_max
= g_dsl_param
.MaxDelayrt
;
1673 RETX_TD_CFG
->td_min
= g_dsl_param
.MinDelayrt
;
1675 *RETX_PLAYOUT_BUFFER_BASE
= ((((unsigned int)g_retx_playout_buffer
| KSEG1
) + 15) & 0xFFFFFFF0) >> 2;
1677 if ( g_dsl_param
.ServiceSpecificReTx
) {
1678 *RETX_SERVICE_HEADER_CFG
= g_dsl_param
.ReTxPVC
<< 4;
1679 if ( g_dsl_param
.ReTxPVC
== 0 )
1680 *RETX_MASK_HEADER_CFG
= 1;
1682 *RETX_MASK_HEADER_CFG
= 0;
1685 *RETX_SERVICE_HEADER_CFG
= 0;
1686 *RETX_MASK_HEADER_CFG
= 0;
1696 RETX_TSYNC_CFG
->fw_alpha
= 7;
1698 *RETX_SERVICE_HEADER_CFG
= 0;
1699 *RETX_MASK_HEADER_CFG
= 0;
1705 if ( retx_en
!= RETX_MODE_CFG
->retx_en
) {
1706 unsigned int pid_mask
, vci_mask
;
1717 max_htu
= *CFG_WRX_HTUTS
;
1718 for ( i
= OAM_HTU_ENTRY_NUMBER
; i
< max_htu
; i
++ )
1719 if ( HTU_ENTRY(i
)->vld
) {
1720 HTU_MASK(i
)->pid_mask
= pid_mask
;
1721 HTU_MASK(i
)->vci_mask
= vci_mask
;
1725 if ( new_retx_htu
!= g_retx_htu
) {
1726 int conn
, retx_conn
;
1728 g_retx_htu
= new_retx_htu
;
1731 max_htu
= *CFG_WRX_HTUTS
;
1732 for ( i
= OAM_HTU_ENTRY_NUMBER
; i
< max_htu
; i
++ )
1733 if ( HTU_ENTRY(i
)->vld
)
1734 HTU_MASK(i
)->clp
= 0;
1736 for ( conn
= 0; conn
< MAX_PVC_NUMBER
; conn
++ )
1737 if ( g_atm_priv_data
.conn
[conn
].vcc
&& g_atm_priv_data
.conn
[conn
].vcc
->qos
.aal
== ATM_AAL5
&& !HTU_ENTRY(conn
+ OAM_HTU_ENTRY_NUMBER
)->clp
) {
1738 retx_conn
= (conn
+ 8) % 16; // ReTX queue
1740 if ( retx_conn
< MAX_PVC_NUMBER
&& test_and_set_bit(retx_conn
, &g_atm_priv_data
.conn_table
) == 0 ) {
1741 g_atm_priv_data
.conn
[retx_conn
].vcc
= g_atm_priv_data
.conn
[conn
].vcc
;
1742 set_htu_entry(g_atm_priv_data
.conn
[conn
].vcc
->vpi
, g_atm_priv_data
.conn
[conn
].vcc
->vci
, retx_conn
, g_atm_priv_data
.conn
[conn
].vcc
->qos
.aal
== ATM_AAL5
? 1 : 0, 1);
1745 err("Queue number %d for ReTX queue of PVC(%d.%d) is not available!", retx_conn
, g_atm_priv_data
.conn
[conn
].vcc
->vpi
, g_atm_priv_data
.conn
[conn
].vcc
->vci
);
1751 for ( retx_conn
= 0; retx_conn
< MAX_PVC_NUMBER
; retx_conn
++ )
1752 if ( g_atm_priv_data
.conn
[retx_conn
].vcc
&& HTU_ENTRY(retx_conn
+ OAM_HTU_ENTRY_NUMBER
)->clp
) {
1753 clear_htu_entry(retx_conn
);
1754 g_atm_priv_data
.conn
[retx_conn
].vcc
= NULL
;
1755 g_atm_priv_data
.conn
[retx_conn
].aal5_vcc_crc_err
= 0;
1756 g_atm_priv_data
.conn
[retx_conn
].aal5_vcc_oversize_sdu
= 0;
1757 clear_bit(retx_conn
, &g_atm_priv_data
.conn_table
);
1760 max_htu
= *CFG_WRX_HTUTS
;
1761 for ( i
= OAM_HTU_ENTRY_NUMBER
; i
< max_htu
; i
++ )
1762 if ( HTU_ENTRY(i
)->vld
)
1763 HTU_MASK(i
)->clp
= 1;
1767 RETX_MODE_CFG
->retx_en
= retx_en
;
1770 p_dsl_param
->update_flag
= 0;
1772 do_gettimeofday(&g_retx_polling_end
);
1775 g_retx_polling_timer
.expires
= jiffies
+ RETX_POLLING_INTERVAL
;
1776 add_timer(&g_retx_polling_timer
);
1778 local_irq_restore(sys_flag
);
1781 static int init_atm_tc_retrans_param(void)
1784 struct DTU_stat_info reset_val
;
1786 RETX_MODE_CFG
->invld_range
= 128;
1787 RETX_MODE_CFG
->buff_size
= RETX_PLAYOUT_FW_BUFF_SIZE
> 4096/32 ? 4096/32 : RETX_PLAYOUT_FW_BUFF_SIZE
;
1788 RETX_MODE_CFG
->retx_en
= 1;
1790 // default fw_alpha equals to default hardware alpha
1791 RETX_TSYNC_CFG
->fw_alpha
= 7;
1792 RETX_TSYNC_CFG
->sync_inp
= 0;
1794 RETX_TD_CFG
->td_max
= 0;
1795 RETX_TD_CFG
->td_min
= 0;
1797 // *RETX_PLAYOUT_BUFFER_BASE = KSEG1ADDR(g_retx_playout_buffer); // need " >> 2 " ?
1798 *RETX_PLAYOUT_BUFFER_BASE
= ((((unsigned int)g_retx_playout_buffer
| KSEG1
) + 15) & 0xFFFFFFF0) >> 2;
1800 *RETX_SERVICE_HEADER_CFG
= 0;
1801 *RETX_MASK_HEADER_CFG
= 0;
1804 RETX_MIB_TIMER_CFG
->tick_cycle
= 4800;
1805 RETX_MIB_TIMER_CFG
->ticks_per_sec
= 50000;
1807 *LAST_DTU_SID_IN
= 255;
1809 // init DTU_STAT_INFO
1811 memset(&reset_val
, 0, sizeof(reset_val
));
1812 reset_val
.dtu_rd_ptr
= reset_val
.dtu_wr_ptr
= 0xffff;
1814 for(i
= 0 ; i
< 256; i
++) {
1815 DTU_STAT_INFO
[i
] = reset_val
;
1820 static void clear_atm_tc_retrans_param(void)
1822 if ( g_retx_playout_buffer
) {
1823 free_pages(g_retx_playout_buffer
, RETX_PLAYOUT_BUFFER_ORDER
);
1824 g_retx_playout_buffer
= 0;
1830 #if defined(DEBUG_DUMP_SKB) && DEBUG_DUMP_SKB
1831 static void dump_skb(struct sk_buff
*skb
, unsigned int len
, char *title
, int port
, int ch
, int is_tx
)
1835 if ( !(ifx_atm_dbg_enable
& (is_tx
? DBG_ENABLE_MASK_DUMP_SKB_TX
: DBG_ENABLE_MASK_DUMP_SKB_RX
)) )
1838 if ( skb
->len
< len
)
1841 if ( len
> RX_DMA_CH_AAL_BUF_SIZE
) {
1842 printk("too big data length: skb = %08x, skb->data = %08x, skb->len = %d\n", (unsigned int)skb
, (unsigned int)skb
->data
, skb
->len
);
1847 printk("%s (port %d, ch %d)\n", title
, port
, ch
);
1849 printk("%s\n", title
);
1850 printk(" skb->data = %08X, skb->tail = %08X, skb->len = %d\n", (unsigned int)skb
->data
, (unsigned int)skb
->tail
, (int)skb
->len
);
1851 for ( i
= 1; i
<= len
; i
++ ) {
1853 printk(" %4d:", i
- 1);
1854 printk(" %02X", (int)(*((char*)skb
->data
+ i
- 1) & 0xFF));
1858 if ( (i
- 1) % 16 != 0 )
1863 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
1864 static void skb_swap(struct sk_buff
*skb
, unsigned int byteoff
)
1866 unsigned int mac_offset
= ~0;
1867 unsigned int ip_offset
= ~0;
1868 unsigned char tmp
[8];
1869 unsigned char *p
= NULL
;
1871 skb_pull(skb
, byteoff
+ TX_INBAND_HEADER_LENGTH
);
1873 if ( skb
->data
[0] == 0xAA && skb
->data
[1] == 0xAA && skb
->data
[2] == 0x03 ) {
1875 if ( skb
->data
[3] == 0x00 && skb
->data
[4] == 0x80 && skb
->data
[5] == 0xC2 ) {
1877 if ( skb
->data
[22] == 0x08 && skb
->data
[23] == 0x00 ) {
1882 else if ( skb
->data
[31] == 0x21 ) {
1890 if ( skb
->data
[6] == 0x08 && skb
->data
[7] == 0x00 ) {
1896 else if ( skb
->data
[0] == 0xFE && skb
->data
[1] == 0xFE && skb
->data
[2] == 0x03 ) {
1898 if ( skb
->data
[4] == 0x00 && skb
->data
[5] == 0x21 ) {
1905 if ( skb
->data
[0] == 0x00 && skb
->data
[1] == 0x21 ) {
1909 else if ( skb
->data
[0] == 0x00 && skb
->data
[1] == 0x00 ) {
1911 if ( skb
->data
[14] == 0x08 && skb
->data
[15] ==0x00 ) {
1916 else if ( skb
->data
[23] == 0x21 ) {
1928 if ( mac_offset
!= ~0 && !(skb
->data
[mac_offset
] & 0x01) ) {
1929 p
= skb
->data
+ mac_offset
;
1932 memcpy(p
, p
+ 6, 6);
1933 memcpy(p
+ 6, tmp
, 6);
1937 if ( ip_offset
!= ~0 ) {
1938 p
= skb
->data
+ ip_offset
+ 12;
1941 memcpy(p
, p
+ 4, 4);
1942 memcpy(p
+ 4, tmp
, 4);
1947 dma_cache_wback((unsigned long)skb
->data
, (unsigned long)p
- (unsigned long)skb
->data
);
1950 skb_push(skb
, byteoff
+ TX_INBAND_HEADER_LENGTH
);
1954 static INLINE
void proc_file_create(void)
1956 struct proc_dir_entry
*res
;
1958 g_atm_dir
= proc_mkdir("driver/ifx_atm", NULL
);
1960 create_proc_read_entry("version",
1966 res
= create_proc_entry("mib",
1969 if ( res
!= NULL
) {
1970 res
->read_proc
= proc_read_mib
;
1971 res
->write_proc
= proc_write_mib
;
1974 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
1975 res
= create_proc_entry("retx_mib",
1978 if ( res
!= NULL
) {
1979 res
->read_proc
= proc_read_retx_mib
;
1980 res
->write_proc
= proc_write_retx_mib
;
1984 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
1985 res
= create_proc_entry("dbg",
1988 if ( res
!= NULL
) {
1989 res
->read_proc
= proc_read_dbg
;
1990 res
->write_proc
= proc_write_dbg
;
1993 res
= create_proc_entry("mem",
1997 res
->write_proc
= proc_write_mem
;
1999 #if defined(CONFIG_AR9) || defined(CONFIG_VR9) || defined(CONFIG_DANUBE) || defined(CONFIG_AMAZON_SE)
2000 res
= create_proc_entry("pp32",
2003 if ( res
!= NULL
) {
2004 res
->read_proc
= proc_read_pp32
;
2005 res
->write_proc
= proc_write_pp32
;
2010 #if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
2011 create_proc_read_entry("htu",
2017 create_proc_read_entry("txq",
2023 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
2024 create_proc_read_entry("retx_fw",
2030 res
= create_proc_entry("retx_stats",
2033 if ( res
!= NULL
) {
2034 res
->read_proc
= proc_read_retx_stats
;
2035 res
->write_proc
= proc_write_retx_stats
;
2038 res
= create_proc_entry("retx_cfg",
2041 if ( res
!= NULL
) {
2042 res
->read_proc
= proc_read_retx_cfg
;
2043 res
->write_proc
= proc_write_retx_cfg
;
2046 create_proc_read_entry("retx_dsl_param",
2049 proc_read_retx_dsl_param
,
2055 static INLINE
void proc_file_delete(void)
2057 #if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
2058 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
2059 remove_proc_entry("retx_dsl_param", g_atm_dir
);
2061 remove_proc_entry("retx_cfg", g_atm_dir
);
2063 remove_proc_entry("retx_stats", g_atm_dir
);
2065 remove_proc_entry("retx_fw", g_atm_dir
);
2068 remove_proc_entry("txq", g_atm_dir
);
2070 remove_proc_entry("htu", g_atm_dir
);
2073 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
2074 #if defined(CONFIG_AR9) || defined(CONFIG_VR9) || defined(CONFIG_DANUBE) || defined(CONFIG_AMAZON_SE)
2075 remove_proc_entry("pp32", g_atm_dir
);
2078 remove_proc_entry("mem", g_atm_dir
);
2080 remove_proc_entry("dbg", g_atm_dir
);
2083 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
2084 remove_proc_entry("retx_mib", g_atm_dir
);
2087 remove_proc_entry("mib", g_atm_dir
);
2089 remove_proc_entry("version", g_atm_dir
);
2091 remove_proc_entry("driver/ifx_atm", NULL
);
2094 static int proc_read_version(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
2098 len
+= ifx_atm_version(buf
+ len
);
2100 if ( offset
>= len
) {
2105 *start
= buf
+ offset
;
2106 if ( (len
-= offset
) > count
)
2112 static int proc_read_mib(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2116 len
+= sprintf(page
+ off
+ len
, "Firmware\n");
2117 len
+= sprintf(page
+ off
+ len
, " wrx_drophtu_cell = %u\n", WAN_MIB_TABLE
->wrx_drophtu_cell
);
2118 len
+= sprintf(page
+ off
+ len
, " wrx_dropdes_pdu = %u\n", WAN_MIB_TABLE
->wrx_dropdes_pdu
);
2119 len
+= sprintf(page
+ off
+ len
, " wrx_correct_pdu = %u\n", WAN_MIB_TABLE
->wrx_correct_pdu
);
2120 len
+= sprintf(page
+ off
+ len
, " wrx_err_pdu = %u\n", WAN_MIB_TABLE
->wrx_err_pdu
);
2121 len
+= sprintf(page
+ off
+ len
, " wrx_dropdes_cell = %u\n", WAN_MIB_TABLE
->wrx_dropdes_cell
);
2122 len
+= sprintf(page
+ off
+ len
, " wrx_correct_cell = %u\n", WAN_MIB_TABLE
->wrx_correct_cell
);
2123 len
+= sprintf(page
+ off
+ len
, " wrx_err_cell = %u\n", WAN_MIB_TABLE
->wrx_err_cell
);
2124 len
+= sprintf(page
+ off
+ len
, " wrx_total_byte = %u\n", WAN_MIB_TABLE
->wrx_total_byte
);
2125 len
+= sprintf(page
+ off
+ len
, " wtx_total_pdu = %u\n", WAN_MIB_TABLE
->wtx_total_pdu
);
2126 len
+= sprintf(page
+ off
+ len
, " wtx_total_cell = %u\n", WAN_MIB_TABLE
->wtx_total_cell
);
2127 len
+= sprintf(page
+ off
+ len
, " wtx_total_byte = %u\n", WAN_MIB_TABLE
->wtx_total_byte
);
2128 len
+= sprintf(page
+ off
+ len
, "Driver\n");
2129 len
+= sprintf(page
+ off
+ len
, " wrx_pdu = %u\n", g_atm_priv_data
.wrx_pdu
);
2130 len
+= sprintf(page
+ off
+ len
, " wrx_drop_pdu = %u\n", g_atm_priv_data
.wrx_drop_pdu
);
2131 len
+= sprintf(page
+ off
+ len
, " wtx_pdu = %u\n", g_atm_priv_data
.wtx_pdu
);
2132 len
+= sprintf(page
+ off
+ len
, " wtx_err_pdu = %u\n", g_atm_priv_data
.wtx_err_pdu
);
2133 len
+= sprintf(page
+ off
+ len
, " wtx_drop_pdu = %u\n", g_atm_priv_data
.wtx_drop_pdu
);
2140 static int proc_write_mib(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2146 len
= count
< sizeof(str
) ? count
: sizeof(str
) - 1;
2147 rlen
= len
- copy_from_user(str
, buf
, len
);
2148 while ( rlen
&& str
[rlen
- 1] <= ' ' )
2151 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
2155 if ( stricmp(p
, "clear") == 0 || stricmp(p
, "clear all") == 0
2156 || stricmp(p
, "clean") == 0 || stricmp(p
, "clean all") == 0 ) {
2157 memset(WAN_MIB_TABLE
, 0, sizeof(*WAN_MIB_TABLE
));
2158 g_atm_priv_data
.wrx_pdu
= 0;
2159 g_atm_priv_data
.wrx_drop_pdu
= 0;
2160 g_atm_priv_data
.wtx_pdu
= 0;
2161 g_atm_priv_data
.wtx_err_pdu
= 0;
2162 g_atm_priv_data
.wtx_drop_pdu
= 0;
2168 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
2170 static int proc_read_retx_mib(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2174 printk("Retx FW DTU MIB :\n");
2175 printk(" rx_total_dtu = %u\n", *URETX_RX_TOTAL_DTU
);
2176 printk(" rx_bad_dtu = %u\n", *URETX_RX_BAD_DTU
);
2177 printk(" rx_good_dtu = %u\n", *URETX_RX_GOOD_DTU
);
2178 printk(" rx_corrected_dtu = %u\n", *URETX_RX_CORRECTED_DTU
);
2179 printk(" rx_outofdate_dtu = %u\n", *URETX_RX_OUTOFDATE_DTU
);
2180 printk(" rx_duplicate_dtu = %u\n", *URETX_RX_DUPLICATE_DTU
);
2181 printk(" rx_timeout_dtu = %u\n", *URETX_RX_TIMEOUT_DTU
);
2182 printk(" RxDTURetransmittedCNT = %u\n", *RxDTURetransmittedCNT
);
2185 printk("Retx Standard DTU MIB:\n");
2186 printk(" RxLastEFB = %u\n", *RxLastEFBCNT
);
2187 printk(" RxDTUCorrectedCNT = %u\n", *RxDTUCorrectedCNT
);
2188 printk(" RxDTUCorruptedCNT = %u\n", *RxDTUCorruptedCNT
);
2189 printk(" RxRetxDTUUncorrectedCNT = %u\n", *RxRetxDTUUncorrectedCNT
);
2192 printk("Retx FW Cell MIB :\n");
2193 printk(" bc0_total_cell = %u\n", *WRX_BC0_CELL_NUM
);
2194 printk(" bc0_drop_cell = %u\n", *WRX_BC0_DROP_CELL_NUM
);
2195 printk(" bc0_nonretx_cell = %u\n", *WRX_BC0_NONRETX_CELL_NUM
);
2196 printk(" bc0_retx_cell = %u\n", *WRX_BC0_RETX_CELL_NUM
);
2197 printk(" bc0_outofdate_cell = %u\n", *WRX_BC0_OUTOFDATE_CELL_NUM
);
2198 printk(" bc0_directup_cell = %u\n", *WRX_BC0_DIRECTUP_NUM
);
2199 printk(" bc0_to_pb_total_cell = %u\n", *WRX_BC0_PBW_TOTAL_NUM
);
2200 printk(" bc0_to_pb_succ_cell = %u\n", *WRX_BC0_PBW_SUCC_NUM
);
2201 printk(" bc0_to_pb_fail_cell = %u\n", *WRX_BC0_PBW_FAIL_NUM
);
2202 printk(" bc1_total_cell = %u\n", *WRX_BC1_CELL_NUM
);
2206 printk("ATM Rx AAL5/OAM MIB:\n");
2207 printk(" wrx_drophtu_cell = %u\n", WAN_MIB_TABLE
->wrx_drophtu_cell
);
2208 printk(" wrx_dropdes_pdu = %u\n", WAN_MIB_TABLE
->wrx_dropdes_pdu
);
2210 printk(" wrx_correct_pdu = %-10u ", WAN_MIB_TABLE
->wrx_correct_pdu
);
2211 if ( WAN_MIB_TABLE
->wrx_correct_pdu
== 0 )
2217 for ( i
= 0; i
< 16; ++i
) {
2218 if ( WRX_PER_PVC_CORRECT_PDU_BASE
[i
] )
2219 printk("q%-2d = %-10u , ", i
, WRX_PER_PVC_CORRECT_PDU_BASE
[i
]);
2224 printk(" wrx_err_pdu = %-10u ", WAN_MIB_TABLE
->wrx_err_pdu
);
2225 if ( WAN_MIB_TABLE
->wrx_err_pdu
== 0 )
2231 for ( i
= 0; i
< 16; ++i
) {
2232 if ( WRX_PER_PVC_ERROR_PDU_BASE
[i
] )
2233 printk("q%-2d = %-10u , ", i
, WRX_PER_PVC_ERROR_PDU_BASE
[i
] );
2238 printk(" wrx_dropdes_cell = %u\n", WAN_MIB_TABLE
->wrx_dropdes_cell
);
2239 printk(" wrx_correct_cell = %u\n", WAN_MIB_TABLE
->wrx_correct_cell
);
2240 printk(" wrx_err_cell = %u\n", WAN_MIB_TABLE
->wrx_err_cell
);
2241 printk(" wrx_total_byte = %u\n", WAN_MIB_TABLE
->wrx_total_byte
);
2244 printk("ATM Tx MIB:\n");
2245 printk(" wtx_total_pdu = %u\n", WAN_MIB_TABLE
->wtx_total_pdu
);
2246 printk(" wtx_total_cell = %u\n", WAN_MIB_TABLE
->wtx_total_cell
);
2247 printk(" wtx_total_byte = %u\n", WAN_MIB_TABLE
->wtx_total_byte
);
2250 printk("Debugging Info:\n");
2251 printk(" Firmware version = %d.%d.%d.%d.%d.%d\n",
2252 (int)FW_VER_ID
->family
, (int)FW_VER_ID
->fwtype
, (int)FW_VER_ID
->interface
,
2253 (int)FW_VER_ID
->fwmode
, (int)FW_VER_ID
->major
, (int)FW_VER_ID
->minor
);
2255 printk(" retx_alpha_switch_to_hunt_times = %u\n", *URETX_ALPHA_SWITCH_TO_HUNT_TIMES
);
2264 static int proc_write_retx_mib(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2271 len
= count
< sizeof(str
) ? count
: sizeof(str
) - 1;
2272 rlen
= len
- copy_from_user(str
, buf
, len
);
2273 while ( rlen
&& str
[rlen
- 1] <= ' ' )
2276 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
2280 if ( stricmp(p
, "clean") == 0 || stricmp(p
, "clear") == 0 || stricmp(p
, "clear_all") == 0) {
2281 *URETX_RX_TOTAL_DTU
= 0;
2282 *URETX_RX_BAD_DTU
= 0;
2283 *URETX_RX_GOOD_DTU
= 0;
2284 *URETX_RX_CORRECTED_DTU
= 0;
2285 *URETX_RX_OUTOFDATE_DTU
= 0;
2286 *URETX_RX_DUPLICATE_DTU
= 0;
2287 *URETX_RX_TIMEOUT_DTU
= 0;
2288 *RxDTURetransmittedCNT
= 0;
2290 *WRX_BC0_CELL_NUM
= 0;
2291 *WRX_BC0_DROP_CELL_NUM
= 0;
2292 *WRX_BC0_NONRETX_CELL_NUM
= 0;
2293 *WRX_BC0_RETX_CELL_NUM
= 0;
2294 *WRX_BC0_OUTOFDATE_CELL_NUM
= 0;
2295 *WRX_BC0_DIRECTUP_NUM
= 0;
2296 *WRX_BC0_PBW_TOTAL_NUM
= 0;
2297 *WRX_BC0_PBW_SUCC_NUM
= 0;
2298 *WRX_BC0_PBW_FAIL_NUM
= 0;
2299 *WRX_BC1_CELL_NUM
= 0;
2301 for ( i
= 0; i
< 16; ++i
) {
2302 WRX_PER_PVC_CORRECT_PDU_BASE
[i
] = 0;
2303 WRX_PER_PVC_ERROR_PDU_BASE
[i
] = 0;
2306 WAN_MIB_TABLE
->wrx_drophtu_cell
= 0;
2307 WAN_MIB_TABLE
->wrx_dropdes_pdu
= 0;
2308 WAN_MIB_TABLE
->wrx_correct_pdu
= 0;
2309 WAN_MIB_TABLE
->wrx_err_pdu
= 0;
2310 WAN_MIB_TABLE
->wrx_dropdes_cell
= 0;
2311 WAN_MIB_TABLE
->wrx_correct_cell
= 0;
2312 WAN_MIB_TABLE
->wrx_err_cell
= 0;
2313 WAN_MIB_TABLE
->wrx_total_byte
= 0;
2315 WAN_MIB_TABLE
->wtx_total_pdu
= 0;
2316 WAN_MIB_TABLE
->wtx_total_cell
= 0;
2317 WAN_MIB_TABLE
->wtx_total_byte
= 0;
2319 *URETX_ALPHA_SWITCH_TO_HUNT_TIMES
= 0;
2321 if (stricmp(p
, "clear_all") == 0) {
2323 *RxDTUCorrectedCNT
= 0;
2324 *RxDTUCorruptedCNT
= 0;
2325 *RxRetxDTUUncorrectedCNT
= 0;
2334 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
2336 static int proc_read_dbg(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2340 len
+= sprintf(page
+ off
+ len
, "error print - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_ERR
) ? "enabled" : "disabled");
2341 len
+= sprintf(page
+ off
+ len
, "debug print - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DEBUG_PRINT
) ? "enabled" : "disabled");
2342 len
+= sprintf(page
+ off
+ len
, "assert - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_ASSERT
) ? "enabled" : "disabled");
2343 len
+= sprintf(page
+ off
+ len
, "dump rx skb - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_SKB_RX
) ? "enabled" : "disabled");
2344 len
+= sprintf(page
+ off
+ len
, "dump tx skb - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_SKB_TX
) ? "enabled" : "disabled");
2345 len
+= sprintf(page
+ off
+ len
, "qos - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) ? "enabled" : "disabled");
2346 len
+= sprintf(page
+ off
+ len
, "dump init - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_INIT
) ? "enabled" : "disabled");
2347 len
+= sprintf(page
+ off
+ len
, "mac swap - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_MAC_SWAP
) ? "enabled" : "disabled");
2354 static int proc_write_dbg(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2356 static const char *dbg_enable_mask_str
[] = {
2375 static const int dbg_enable_mask_str_len
[] = {
2386 unsigned int dbg_enable_mask
[] = {
2387 DBG_ENABLE_MASK_ERR
,
2388 DBG_ENABLE_MASK_DEBUG_PRINT
,
2389 DBG_ENABLE_MASK_ASSERT
,
2390 DBG_ENABLE_MASK_DUMP_SKB_RX
,
2391 DBG_ENABLE_MASK_DUMP_SKB_TX
,
2392 DBG_ENABLE_MASK_DUMP_QOS
,
2393 DBG_ENABLE_MASK_DUMP_INIT
,
2394 DBG_ENABLE_MASK_MAC_SWAP
,
2399 int str_buff_len
= 1024;
2407 str
= vmalloc(str_buff_len
);
2412 len
= count
< str_buff_len
? count
: str_buff_len
- 1;
2413 rlen
= len
- copy_from_user(str
, buf
, len
);
2414 while ( rlen
&& str
[rlen
- 1] <= ' ' )
2417 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
2423 if ( strincmp(p
, "enable", 6) == 0 ) {
2427 else if ( strincmp(p
, "disable", 7) == 0 ) {
2431 else if ( strincmp(p
, "help", 4) == 0 || *p
== '?' ) {
2432 printk("echo <enable/disable> [err/dbg/assert/rx/tx/init/all] > /proc/eth/dbg\n");
2438 ifx_atm_dbg_enable
|= DBG_ENABLE_MASK_ALL
& ~DBG_ENABLE_MASK_MAC_SWAP
;
2440 ifx_atm_dbg_enable
&= ~DBG_ENABLE_MASK_ALL
| DBG_ENABLE_MASK_MAC_SWAP
;
2444 for ( i
= 0; i
< NUM_ENTITY(dbg_enable_mask_str
); i
++ )
2445 if ( strincmp(p
, dbg_enable_mask_str
[i
], dbg_enable_mask_str_len
[i
]) == 0 ) {
2447 ifx_atm_dbg_enable
|= dbg_enable_mask
[i
>> 1];
2449 ifx_atm_dbg_enable
&= ~dbg_enable_mask
[i
>> 1];
2450 p
+= dbg_enable_mask_str_len
[i
];
2453 } while ( i
< NUM_ENTITY(dbg_enable_mask_str
) );
2461 static inline unsigned long sb_addr_to_fpi_addr_convert(unsigned long sb_addr
)
2463 #define PP32_SB_ADDR_END 0xFFFF
2465 if ( sb_addr
< PP32_SB_ADDR_END
)
2466 return (unsigned long)SB_BUFFER(sb_addr
);
2471 static int proc_write_mem(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2478 int local_buf_size
= 1024;
2479 char *local_buf
= NULL
;
2481 local_buf
= vmalloc(local_buf_size
);
2486 len
= local_buf_size
< count
? local_buf_size
- 1 : count
;
2487 len
= len
- copy_from_user(local_buf
, buf
, len
);
2492 while ( get_token(&p1
, &p2
, &len
, &colon
) ) {
2493 if ( stricmp(p1
, "w") == 0 || stricmp(p1
, "write") == 0 || stricmp(p1
, "r") == 0 || stricmp(p1
, "read") == 0 )
2501 ignore_space(&p2
, &len
);
2502 p
= (unsigned long *)get_number(&p2
, &len
, 1);
2503 p
= (unsigned long *)sb_addr_to_fpi_addr_convert((unsigned long)p
);
2505 if ( (unsigned int)p
>= KSEG0
)
2507 ignore_space(&p2
, &len
);
2508 if ( !len
|| !((*p2
>= '0' && *p2
<= '9') || (*p2
>= 'a' && *p2
<= 'f') || (*p2
>= 'A' && *p2
<= 'F')) )
2511 *p
++ = (unsigned int)get_number(&p2
, &len
, 1);
2514 else if ( *p1
== 'r' ) {
2515 ignore_space(&p2
, &len
);
2516 p
= (unsigned long *)get_number(&p2
, &len
, 1);
2517 p
= (unsigned long *)sb_addr_to_fpi_addr_convert((unsigned long)p
);
2519 if ( (unsigned int)p
>= KSEG0
) {
2520 ignore_space(&p2
, &len
);
2521 n
= (int)get_number(&p2
, &len
, 0);
2529 n
+= (l
= ((int)p
>> 2) & 0x03);
2530 p
= (unsigned long *)((unsigned int)p
& ~0x0F);
2531 for ( i
= 0; i
< n
; i
++ ) {
2532 if ( (i
& 0x03) == 0 ) {
2533 printk("%08X:", (unsigned int)p
);
2541 data
= (unsigned int)*p
;
2542 printk(" %08X", data
);
2543 for ( k
= 0; k
< 4; k
++ ) {
2544 c
= ((char*)&data
)[k
];
2545 pch
[k
] = c
< ' ' ? '.' : c
;
2550 if ( (i
& 0x03) == 0x03 ) {
2552 printk(" ; %s\n", str
);
2555 if ( (n
& 0x03) != 0x00 ) {
2556 for ( k
= 4 - (n
& 0x03); k
> 0; k
-- )
2559 printk(" ; %s\n", str
);
2569 #if defined(CONFIG_AR9) || defined(CONFIG_VR9)
2571 static int proc_read_pp32(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2573 static const char *stron
= " on";
2574 static const char *stroff
= "off";
2585 for ( pp32
= 0; pp32
< NUM_OF_PP32
; pp32
++ ) {
2588 len
+= sprintf(page
+ off
+ len
, "===== pp32 core %d =====\n", pp32
);
2591 if ( (*PP32_FREEZE
& (1 << (pp32
<< 4))) != 0 ) {
2592 sprintf(str
, "freezed");
2599 else if ( PP32_CPU_USER_STOPPED(pp32
) || PP32_CPU_USER_BREAKIN_RCV(pp32
) || PP32_CPU_USER_BREAKPOINT_MET(pp32
) ) {
2601 if ( PP32_CPU_USER_STOPPED(pp32
) )
2602 strlength
+= sprintf(str
+ strlength
, "stopped");
2603 if ( PP32_CPU_USER_BREAKPOINT_MET(pp32
) )
2604 strlength
+= sprintf(str
+ strlength
, strlength
? " | breakpoint" : "breakpoint");
2605 if ( PP32_CPU_USER_BREAKIN_RCV(pp32
) )
2606 strlength
+= sprintf(str
+ strlength
, strlength
? " | breakin" : "breakin");
2610 else if ( PP32_CPU_CUR_PC(pp32
) == PP32_CPU_CUR_PC(pp32
) ) {
2611 sprintf(str
, "hang");
2616 sprintf(str
, "running");
2617 cur_context
= PP32_BRK_CUR_CONTEXT(pp32
);
2618 len
+= sprintf(page
+ off
+ len
, "Context: %d, PC: 0x%04x, %s\n", cur_context
, PP32_CPU_CUR_PC(pp32
), str
);
2620 if ( PP32_CPU_USER_BREAKPOINT_MET(pp32
) ) {
2622 if ( PP32_BRK_PC_MET(pp32
, 0) )
2623 strlength
+= sprintf(str
+ strlength
, "pc0");
2624 if ( PP32_BRK_PC_MET(pp32
, 1) )
2625 strlength
+= sprintf(str
+ strlength
, strlength
? " | pc1" : "pc1");
2626 if ( PP32_BRK_DATA_ADDR_MET(pp32
, 0) )
2627 strlength
+= sprintf(str
+ strlength
, strlength
? " | daddr0" : "daddr0");
2628 if ( PP32_BRK_DATA_ADDR_MET(pp32
, 1) )
2629 strlength
+= sprintf(str
+ strlength
, strlength
? " | daddr1" : "daddr1");
2630 if ( PP32_BRK_DATA_VALUE_RD_MET(pp32
, 0) ) {
2631 strlength
+= sprintf(str
+ strlength
, strlength
? " | rdval0" : "rdval0");
2632 if ( PP32_BRK_DATA_VALUE_RD_LO_EQ(pp32
, 0) ) {
2633 if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32
, 0) )
2634 strlength
+= sprintf(str
+ strlength
, " ==");
2636 strlength
+= sprintf(str
+ strlength
, " <=");
2638 else if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32
, 0) )
2639 strlength
+= sprintf(str
+ strlength
, " >=");
2641 if ( PP32_BRK_DATA_VALUE_RD_MET(pp32
, 1) ) {
2642 strlength
+= sprintf(str
+ strlength
, strlength
? " | rdval1" : "rdval1");
2643 if ( PP32_BRK_DATA_VALUE_RD_LO_EQ(pp32
, 1) ) {
2644 if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32
, 1) )
2645 strlength
+= sprintf(str
+ strlength
, " ==");
2647 strlength
+= sprintf(str
+ strlength
, " <=");
2649 else if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32
, 1) )
2650 strlength
+= sprintf(str
+ strlength
, " >=");
2652 if ( PP32_BRK_DATA_VALUE_WR_MET(pp32
, 0) ) {
2653 strlength
+= sprintf(str
+ strlength
, strlength
? " | wtval0" : "wtval0");
2654 if ( PP32_BRK_DATA_VALUE_WR_LO_EQ(pp32
, 0) ) {
2655 if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32
, 0) )
2656 strlength
+= sprintf(str
+ strlength
, " ==");
2658 strlength
+= sprintf(str
+ strlength
, " <=");
2660 else if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32
, 0) )
2661 strlength
+= sprintf(str
+ strlength
, " >=");
2663 if ( PP32_BRK_DATA_VALUE_WR_MET(pp32
, 1) ) {
2664 strlength
+= sprintf(str
+ strlength
, strlength
? " | wtval1" : "wtval1");
2665 if ( PP32_BRK_DATA_VALUE_WR_LO_EQ(pp32
, 1) ) {
2666 if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32
, 1) )
2667 strlength
+= sprintf(str
+ strlength
, " ==");
2669 strlength
+= sprintf(str
+ strlength
, " <=");
2671 else if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32
, 1) )
2672 strlength
+= sprintf(str
+ strlength
, " >=");
2674 len
+= sprintf(page
+ off
+ len
, "break reason: %s\n", str
);
2679 len
+= sprintf(page
+ off
+ len
, "General Purpose Register (Context %d):\n", cur_context
);
2680 for ( i
= 0; i
< 4; i
++ ) {
2681 for ( j
= 0; j
< 4; j
++ )
2682 len
+= sprintf(page
+ off
+ len
, " %2d: %08x", i
+ j
* 4, *PP32_GP_CONTEXTi_REGn(pp32
, cur_context
, i
+ j
* 4));
2683 len
+= sprintf(page
+ off
+ len
, "\n");
2687 len
+= sprintf(page
+ off
+ len
, "break out on: break in - %s, stop - %s\n",
2688 PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(pp32
) ? stron
: stroff
,
2689 PP32_CTRL_OPT_BREAKOUT_ON_STOP(pp32
) ? stron
: stroff
);
2690 len
+= sprintf(page
+ off
+ len
, " stop on: break in - %s, break point - %s\n",
2691 PP32_CTRL_OPT_STOP_ON_BREAKIN(pp32
) ? stron
: stroff
,
2692 PP32_CTRL_OPT_STOP_ON_BREAKPOINT(pp32
) ? stron
: stroff
);
2693 len
+= sprintf(page
+ off
+ len
, "breakpoint:\n");
2694 len
+= sprintf(page
+ off
+ len
, " pc0: 0x%08x, %s\n", *PP32_BRK_PC(pp32
, 0), PP32_BRK_GRPi_PCn(pp32
, 0, 0) ? "group 0" : "off");
2695 len
+= sprintf(page
+ off
+ len
, " pc1: 0x%08x, %s\n", *PP32_BRK_PC(pp32
, 1), PP32_BRK_GRPi_PCn(pp32
, 1, 1) ? "group 1" : "off");
2696 len
+= sprintf(page
+ off
+ len
, " daddr0: 0x%08x, %s\n", *PP32_BRK_DATA_ADDR(pp32
, 0), PP32_BRK_GRPi_DATA_ADDRn(pp32
, 0, 0) ? "group 0" : "off");
2697 len
+= sprintf(page
+ off
+ len
, " daddr1: 0x%08x, %s\n", *PP32_BRK_DATA_ADDR(pp32
, 1), PP32_BRK_GRPi_DATA_ADDRn(pp32
, 1, 1) ? "group 1" : "off");
2698 len
+= sprintf(page
+ off
+ len
, " rdval0: 0x%08x\n", *PP32_BRK_DATA_VALUE_RD(pp32
, 0));
2699 len
+= sprintf(page
+ off
+ len
, " rdval1: 0x%08x\n", *PP32_BRK_DATA_VALUE_RD(pp32
, 1));
2700 len
+= sprintf(page
+ off
+ len
, " wrval0: 0x%08x\n", *PP32_BRK_DATA_VALUE_WR(pp32
, 0));
2701 len
+= sprintf(page
+ off
+ len
, " wrval1: 0x%08x\n", *PP32_BRK_DATA_VALUE_WR(pp32
, 1));
2709 static int proc_write_pp32(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2714 int str_buff_len
= 1024;
2720 str
= vmalloc(str_buff_len
);
2725 len
= count
< str_buff_len
? count
: str_buff_len
- 1;
2726 rlen
= len
- copy_from_user(str
, buf
, len
);
2727 while ( rlen
&& str
[rlen
- 1] <= ' ' )
2730 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
2736 if ( strincmp(p
, "pp32 ", 5) == 0 ) {
2740 while ( rlen
> 0 && *p
>= '0' && *p
<= '9' ) {
2745 while ( rlen
> 0 && *p
&& *p
<= ' ' ) {
2750 if ( pp32
>= NUM_OF_PP32
) {
2751 err("incorrect pp32 index - %d", pp32
);
2757 if ( stricmp(p
, "start") == 0 )
2758 *PP32_CTRL_CMD(pp32
) = PP32_CTRL_CMD_RESTART
;
2759 else if ( stricmp(p
, "stop") == 0 )
2760 *PP32_CTRL_CMD(pp32
) = PP32_CTRL_CMD_STOP
;
2761 else if ( stricmp(p
, "step") == 0 )
2762 *PP32_CTRL_CMD(pp32
) = PP32_CTRL_CMD_STEP
;
2764 else if ( stricmp(p
, "restart") == 0 )
2765 *PP32_FREEZE
&= ~(1 << (pp32
<< 4));
2766 else if ( stricmp(p
, "freeze") == 0 )
2767 *PP32_FREEZE
|= 1 << (pp32
<< 4);
2769 else if ( strincmp(p
, "pc0 ", 4) == 0 ) {
2772 if ( stricmp(p
, "off") == 0 ) {
2773 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_PCn_OFF(0, 0);
2774 *PP32_BRK_PC_MASK(pp32
, 0) = PP32_BRK_CONTEXT_MASK_EN
;
2775 *PP32_BRK_PC(pp32
, 0) = 0;
2778 addr
= get_number(&p
, &rlen
, 1);
2779 *PP32_BRK_PC(pp32
, 0) = addr
;
2780 *PP32_BRK_PC_MASK(pp32
, 0) = PP32_BRK_CONTEXT_MASK_EN
| PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
2781 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_PCn_ON(0, 0);
2784 else if ( strincmp(p
, "pc1 ", 4) == 0 ) {
2787 if ( stricmp(p
, "off") == 0 ) {
2788 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_PCn_OFF(1, 1);
2789 *PP32_BRK_PC_MASK(pp32
, 1) = PP32_BRK_CONTEXT_MASK_EN
;
2790 *PP32_BRK_PC(pp32
, 1) = 0;
2793 addr
= get_number(&p
, &rlen
, 1);
2794 *PP32_BRK_PC(pp32
, 1) = addr
;
2795 *PP32_BRK_PC_MASK(pp32
, 1) = PP32_BRK_CONTEXT_MASK_EN
| PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
2796 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_PCn_ON(1, 1);
2799 else if ( strincmp(p
, "daddr0 ", 7) == 0 ) {
2802 if ( stricmp(p
, "off") == 0 ) {
2803 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_DATA_ADDRn_OFF(0, 0);
2804 *PP32_BRK_DATA_ADDR_MASK(pp32
, 0) = PP32_BRK_CONTEXT_MASK_EN
;
2805 *PP32_BRK_DATA_ADDR(pp32
, 0) = 0;
2808 addr
= get_number(&p
, &rlen
, 1);
2809 *PP32_BRK_DATA_ADDR(pp32
, 0) = addr
;
2810 *PP32_BRK_DATA_ADDR_MASK(pp32
, 0) = PP32_BRK_CONTEXT_MASK_EN
| PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
2811 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_DATA_ADDRn_ON(0, 0);
2814 else if ( strincmp(p
, "daddr1 ", 7) == 0 ) {
2817 if ( stricmp(p
, "off") == 0 ) {
2818 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_DATA_ADDRn_OFF(1, 1);
2819 *PP32_BRK_DATA_ADDR_MASK(pp32
, 1) = PP32_BRK_CONTEXT_MASK_EN
;
2820 *PP32_BRK_DATA_ADDR(pp32
, 1) = 0;
2823 addr
= get_number(&p
, &rlen
, 1);
2824 *PP32_BRK_DATA_ADDR(pp32
, 1) = addr
;
2825 *PP32_BRK_DATA_ADDR_MASK(pp32
, 1) = PP32_BRK_CONTEXT_MASK_EN
| PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
2826 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_DATA_ADDRn_ON(1, 1);
2831 printk("echo \"<command>\" > /proc/driver/ifx_ptm/pp32\n");
2832 printk(" command:\n");
2833 printk(" start - run pp32\n");
2834 printk(" stop - stop pp32\n");
2835 printk(" step - run pp32 with one step only\n");
2836 printk(" pc0 - pc0 <addr>/off, set break point PC0\n");
2837 printk(" pc1 - pc1 <addr>/off, set break point PC1\n");
2838 printk(" daddr0 - daddr0 <addr>/off, set break point data address 0\n");
2839 printk(" daddr0 - daddr1 <addr>/off, set break point data address 1\n");
2840 printk(" help - print this screen\n");
2843 if ( *PP32_BRK_TRIG(pp32
) )
2844 *PP32_CTRL_OPT(pp32
) = PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON
;
2846 *PP32_CTRL_OPT(pp32
) = PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF
;
2851 #elif defined(CONFIG_DANUBE)
2853 static int proc_read_pp32(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2855 static const char *halt_stat
[] = {
2864 static const char *brk_src_data
[] = {
2874 static const char *brk_src_code
[] = {
2885 tsk
= *PP32_DBG_TASK_NO
& 0x03;
2886 len
+= sprintf(page
+ off
+ len
, "Task No %d, PC %04x\n", tsk
, *PP32_DBG_CUR_PC
& 0xFFFF);
2888 if ( !(*PP32_HALT_STAT
& 0x01) )
2889 len
+= sprintf(page
+ off
+ len
, " Halt State: Running\n");
2891 len
+= sprintf(page
+ off
+ len
, " Halt State: Stopped");
2893 for ( bit
= 2, i
= 0; bit
<= (1 << 7); bit
<<= 1, i
++ )
2894 if ( (*PP32_HALT_STAT
& bit
) ) {
2896 len
+= sprintf(page
+ off
+ len
, ", ");
2900 len
+= sprintf(page
+ off
+ len
, " | ");
2901 len
+= sprintf(page
+ off
+ len
, halt_stat
[i
]);
2904 len
+= sprintf(page
+ off
+ len
, "\n");
2906 len
+= sprintf(page
+ off
+ len
, " Regs (Task %d):\n", tsk
);
2907 for ( i
= 0; i
< 8; i
++ )
2908 len
+= sprintf(page
+ off
+ len
, " %2d. %08x %2d. %08x\n", i
, *PP32_DBG_REG_BASE(tsk
, i
), i
+ 8, *PP32_DBG_REG_BASE(tsk
, i
+ 8));
2911 len
+= sprintf(page
+ off
+ len
, " Break Src: data1 - %s, data0 - %s, pc3 - %s, pc2 - %s, pc1 - %s, pc0 - %s\n",
2912 brk_src_data
[(*PP32_BRK_SRC
>> 11) & 0x07],
2913 brk_src_data
[(*PP32_BRK_SRC
>> 8) & 0x07],
2914 brk_src_code
[(*PP32_BRK_SRC
>> 3) & 0x01],
2915 brk_src_code
[(*PP32_BRK_SRC
>> 2) & 0x01],
2916 brk_src_code
[(*PP32_BRK_SRC
>> 1) & 0x01],
2917 brk_src_code
[*PP32_BRK_SRC
& 0x01]);
2919 for ( i
= 0; i
< 4; i
++ )
2920 len
+= sprintf(page
+ off
+ len
, " pc%d: %04x - %04x\n", i
, *PP32_DBG_PC_MIN(i
), *PP32_DBG_PC_MAX(i
));
2922 for ( i
= 0; i
< 2; i
++ )
2923 len
+= sprintf(page
+ off
+ len
, " data%d: %04x - %04x (%08x)\n", i
, *PP32_DBG_DATA_MIN(i
), *PP32_DBG_DATA_MAX(i
), *PP32_DBG_DATA_VAL(i
));
2930 static int proc_write_pp32(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2936 int str_buff_len
= 2048;
2937 str
= vmalloc(str_buff_len
);
2941 len
= count
< str_buff_len
? count
: str_buff_len
- 1;
2942 rlen
= len
- copy_from_user(str
, buf
, len
);
2943 while ( rlen
&& str
[rlen
- 1] <= ' ' )
2946 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
2951 if ( stricmp(p
, "start") == 0 )
2952 *PP32_DBG_CTRL
= DBG_CTRL_START_SET(1);
2953 else if ( stricmp(p
, "stop") == 0 )
2954 *PP32_DBG_CTRL
= DBG_CTRL_STOP_SET(1);
2955 else if ( stricmp(p
, "step") == 0 )
2956 *PP32_DBG_CTRL
= DBG_CTRL_STEP_SET(1);
2957 else if ( strincmp(p
, "pc", 2) == 0 && p
[2] >= '0' && p
[2] <= '3' && p
[3] <= ' ' ) {
2959 int on_off_flag
= -1;
2960 int addr_min
, addr_max
;
2964 ignore_space(&p
, &rlen
);
2966 if ( strincmp(p
, "off", 3) == 0 && p
[3] <= ' ' ) {
2971 else if ( strincmp(p
, "on", 2) == 0 && p
[2] <= ' ' ) {
2976 ignore_space(&p
, &rlen
);
2979 addr_min
= get_number(&p
, &rlen
, 1);
2980 ignore_space(&p
, &rlen
);
2982 addr_max
= get_number(&p
, &rlen
, 1);
2984 addr_max
= addr_min
;
2986 *PP32_DBG_PC_MIN(n
) = addr_min
;
2987 *PP32_DBG_PC_MAX(n
) = addr_max
;
2990 if ( on_off_flag
== 0 )
2991 *PP32_BRK_SRC
&= ~(1 << n
);
2992 else if ( on_off_flag
> 0 )
2993 *PP32_BRK_SRC
|= 1 << n
;
2995 else if ( strincmp(p
, "data", 4) == 0 && p
[4] >= '0' && p
[4] <= '1' && p
[5] <= ' ' ) {
2996 const static char *data_cmd_str
[] = {"r", "w", "rw", "w=", "off", "min", "min addr", "max", "max addr", "val", "value"};
2997 const static int data_cmd_len
[] = {1, 1, 2, 2, 3, 3, 8, 3, 8, 3, 5};
2998 const static int data_cmd_idx
[] = {1, 2, 3, 4, 0, 5, 5, 6, 6, 7, 7};
3000 int on_off_flag
= -1, on_off_mask
= 0;
3001 int addr_min
= -1, addr_max
= -1;
3002 int value
= 0, f_got_value
= 0;
3011 ignore_space(&p
, &rlen
);
3014 for ( i
= 0; i
< NUM_ENTITY(data_cmd_str
); i
++ )
3015 if ( strincmp(p
, data_cmd_str
[i
], data_cmd_len
[i
]) == 0 && p
[data_cmd_len
[i
]] <= ' ' ) {
3016 p
+= data_cmd_len
[i
];
3017 rlen
-= data_cmd_len
[i
];
3018 stat
= data_cmd_idx
[i
];
3025 if ( i
== NUM_ENTITY(data_cmd_str
) ) {
3026 if ( (*p
>= '0' && *p
<= '9') || (*p
>= 'a' && *p
<= 'f') || (*p
>= 'A' && *p
<= 'F') ) {
3027 tmp
= get_number(&p
, &rlen
, 1);
3032 else if ( stat
>= 7 ) {
3042 for ( ; rlen
&& *p
> ' '; rlen
--, p
++ );
3046 if ( addr_min
>= 0 )
3047 *PP32_DBG_DATA_MIN(n
) = *PP32_DBG_DATA_MAX(n
) = addr_min
;
3048 if ( addr_max
>= 0 )
3049 *PP32_DBG_DATA_MAX(n
) = addr_max
;
3051 *PP32_DBG_DATA_VAL(n
) = value
;
3052 if ( on_off_mask
&& on_off_flag
>= 0 ) {
3053 on_off_flag
<<= n
? 11 : 8;
3054 on_off_mask
<<= n
? 11 : 8;
3055 *PP32_BRK_SRC
= (*PP32_BRK_SRC
& ~on_off_mask
) | on_off_flag
;
3059 printk("echo \"<command>\" > /proc/eth/etop\n");
3060 printk(" command:\n");
3061 printk(" start - run pp32\n");
3062 printk(" stop - stop pp32\n");
3063 printk(" step - run pp32 with one step only\n");
3064 printk(" pc - pc? [on/off] [min addr] [max addr], set PC break point\n");
3065 printk(" data - data? [r/w/rw/w=/off] [min <addr>] [max <addr>] [val <value>], set data break point\n");
3066 printk(" help - print this screen\n");
3073 #elif defined(CONFIG_AMAZON_SE)
3075 static int proc_read_pp32(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3077 static const char *halt_stat
[] = {
3086 static const char *brk_src_data
[] = {
3096 static const char *brk_src_code
[] = {
3106 len
+= sprintf(page
+ off
+ len
, "Task No %d, PC %04x\n", *PP32_DBG_TASK_NO
& 0x03, *PP32_DBG_CUR_PC
& 0xFFFF);
3108 if ( !(*PP32_HALT_STAT
& 0x01) )
3109 len
+= sprintf(page
+ off
+ len
, " Halt State: Running\n");
3112 len
+= sprintf(page
+ off
+ len
, " Halt State: Stopped");
3114 for ( bit
= 2, i
= 0; bit
<= (1 << 7); bit
<<= 1, i
++ )
3115 if ( (*PP32_HALT_STAT
& bit
) )
3119 len
+= sprintf(page
+ off
+ len
, ", ");
3123 len
+= sprintf(page
+ off
+ len
, " | ");
3124 len
+= sprintf(page
+ off
+ len
, halt_stat
[i
]);
3127 len
+= sprintf(page
+ off
+ len
, "\n");
3130 len
+= sprintf(page
+ off
+ len
, " Break Src: data1 - %s, data0 - %s, pc3 - %s, pc2 - %s, pc1 - %s, pc0 - %s\n",
3131 brk_src_data
[(*PP32_BRK_SRC
>> 11) & 0x07], brk_src_data
[(*PP32_BRK_SRC
>> 8) & 0x07], brk_src_code
[(*PP32_BRK_SRC
>> 3) & 0x01], brk_src_code
[(*PP32_BRK_SRC
>> 2) & 0x01], brk_src_code
[(*PP32_BRK_SRC
>> 1) & 0x01], brk_src_code
[*PP32_BRK_SRC
& 0x01]);
3133 // for ( i = 0; i < 4; i++ )
3134 // len += sprintf(page + off + len, " pc%d: %04x - %04x\n", i, *PP32_DBG_PC_MIN(i), *PP32_DBG_PC_MAX(i));
3136 // for ( i = 0; i < 2; i++ )
3137 // len += sprintf(page + off + len, " data%d: %04x - %04x (%08x)\n", i, *PP32_DBG_DATA_MIN(i), *PP32_DBG_DATA_MAX(i), *PP32_DBG_DATA_VAL(i));
3144 static int proc_write_pp32(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
3151 len
= count
< sizeof(str
) ? count
: sizeof(str
) - 1;
3152 rlen
= len
- copy_from_user(str
, buf
, len
);
3153 while ( rlen
&& str
[rlen
- 1] <= ' ' )
3156 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
3160 if ( stricmp(str
, "start") == 0 )
3161 *PP32_DBG_CTRL
= DBG_CTRL_RESTART
;
3162 else if ( stricmp(str
, "stop") == 0 )
3163 *PP32_DBG_CTRL
= DBG_CTRL_STOP
;
3164 // else if ( stricmp(str, "step") == 0 )
3165 // *PP32_DBG_CTRL = DBG_CTRL_STEP_SET(1);
3168 printk("echo \"<command>\" > /proc/eth/etop\n");
3169 printk(" command:\n");
3170 printk(" start - run pp32\n");
3171 printk(" stop - stop pp32\n");
3172 // printk(" step - run pp32 with one step only\n");
3173 printk(" help - print this screen\n");
3183 #if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
3185 static INLINE
int print_htu(char *buf
, int i
)
3189 if ( HTU_ENTRY(i
)->vld
) {
3190 len
+= sprintf(buf
+ len
, "%2d. valid\n", i
);
3191 len
+= sprintf(buf
+ len
, " entry 0x%08x - pid %01x vpi %02x vci %04x pti %01x\n", *(unsigned int*)HTU_ENTRY(i
), HTU_ENTRY(i
)->pid
, HTU_ENTRY(i
)->vpi
, HTU_ENTRY(i
)->vci
, HTU_ENTRY(i
)->pti
);
3192 len
+= sprintf(buf
+ len
, " mask 0x%08x - pid %01x vpi %02x vci %04x pti %01x\n", *(unsigned int*)HTU_MASK(i
), HTU_MASK(i
)->pid_mask
, HTU_MASK(i
)->vpi_mask
, HTU_MASK(i
)->vci_mask
, HTU_MASK(i
)->pti_mask
);
3193 len
+= sprintf(buf
+ len
, " result 0x%08x - type: %s, qid: %d", *(unsigned int*)HTU_RESULT(i
), HTU_RESULT(i
)->type
? "cell" : "AAL5", HTU_RESULT(i
)->qid
);
3194 if ( HTU_RESULT(i
)->type
)
3195 len
+= sprintf(buf
+ len
, ", cell id: %d, verification: %s", HTU_RESULT(i
)->cellid
, HTU_RESULT(i
)->ven
? "on" : "off");
3196 len
+= sprintf(buf
+ len
, "\n");
3199 len
+= sprintf(buf
+ len
, "%2d. invalid\n", i
);
3204 static int proc_read_htu(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3207 int len_max
= off
+ count
;
3211 int htuts
= *CFG_WRX_HTUTS
;
3214 str
= vmalloc (1024);
3218 pstr
= *start
= page
;
3220 llen
= sprintf(pstr
, "HTU Table (Max %d):\n", htuts
);
3224 for ( i
= 0; i
< htuts
; i
++ ) {
3225 llen
= print_htu(str
, i
);
3226 if ( len
<= off
&& len
+ llen
> off
) {
3227 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3228 pstr
+= len
+ llen
- off
;
3230 else if ( len
> off
) {
3231 memcpy(pstr
, str
, llen
);
3235 if ( len
>= len_max
)
3236 goto PROC_READ_HTU_OVERRUN_END
;
3243 PROC_READ_HTU_OVERRUN_END
:
3245 return len
- llen
- off
;
3248 static INLINE
int print_tx_queue(char *buf
, int i
)
3252 if ( (*WTX_DMACH_ON
& (1 << i
)) ) {
3253 len
+= sprintf(buf
+ len
, "%2d. valid\n", i
);
3254 len
+= sprintf(buf
+ len
, " queue 0x%08x - sbid %u, qsb vcid %u, qsb %s\n", (unsigned int)WTX_QUEUE_CONFIG(i
), (unsigned int)WTX_QUEUE_CONFIG(i
)->sbid
, (unsigned int)WTX_QUEUE_CONFIG(i
)->qsb_vcid
, WTX_QUEUE_CONFIG(i
)->qsben
? "enable" : "disable");
3255 len
+= sprintf(buf
+ len
, " dma 0x%08x - base %08x, len %u, vlddes %u\n", (unsigned int)WTX_DMA_CHANNEL_CONFIG(i
), WTX_DMA_CHANNEL_CONFIG(i
)->desba
, WTX_DMA_CHANNEL_CONFIG(i
)->deslen
, WTX_DMA_CHANNEL_CONFIG(i
)->vlddes
);
3258 len
+= sprintf(buf
+ len
, "%2d. invalid\n", i
);
3263 static int proc_read_txq(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3266 int len_max
= off
+ count
;
3269 int str_buff_len
= 1024;
3274 str
= vmalloc(str_buff_len
);
3278 pstr
= *start
= page
;
3280 llen
= sprintf(pstr
, "TX Queue Config (Max %d):\n", *CFG_WTX_DCHNUM
);
3284 for ( i
= 0; i
< 16; i
++ ) {
3285 llen
= print_tx_queue(str
, i
);
3286 if ( len
<= off
&& len
+ llen
> off
) {
3287 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3288 pstr
+= len
+ llen
- off
;
3290 else if ( len
> off
) {
3291 memcpy(pstr
, str
, llen
);
3295 if ( len
>= len_max
)
3296 goto PROC_READ_HTU_OVERRUN_END
;
3305 PROC_READ_HTU_OVERRUN_END
:
3307 return len
- llen
- off
;
3310 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
3312 static int proc_read_retx_fw(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3316 unsigned int next_dtu_sid_out
, last_dtu_sid_in
, next_cell_sid_out
, isr_cell_id
;
3317 unsigned int curr_time
, sec_counter
, curr_efb
;
3318 struct Retx_adsl_ppe_intf adsl_ppe_intf
;
3320 adsl_ppe_intf
= *RETX_ADSL_PPE_INTF
;
3321 next_dtu_sid_out
= *NEXT_DTU_SID_OUT
;
3322 last_dtu_sid_in
= *LAST_DTU_SID_IN
;
3323 next_cell_sid_out
= *NEXT_CELL_SID_OUT
;
3324 isr_cell_id
= *ISR_CELL_ID
;
3326 curr_time
= *URetx_curr_time
;
3327 sec_counter
= *URetx_sec_counter
;
3328 curr_efb
= *RxCURR_EFB
;
3331 len
+= sprintf(page
+ off
+ len
, "Adsl-PPE Interface:\n");
3332 len
+= sprintf(page
+ off
+ len
, " dtu_sid = 0x%02x [%3u]\n", adsl_ppe_intf
.dtu_sid
, adsl_ppe_intf
.dtu_sid
);
3333 len
+= sprintf(page
+ off
+ len
, " dtu_timestamp = 0x%02x\n", adsl_ppe_intf
.dtu_timestamp
);
3334 len
+= sprintf(page
+ off
+ len
, " local_time = 0x%02x\n", adsl_ppe_intf
.local_time
);
3335 len
+= sprintf(page
+ off
+ len
, " is_last_cw = %u\n", adsl_ppe_intf
.is_last_cw
);
3336 len
+= sprintf(page
+ off
+ len
, " reinit_flag = %u\n", adsl_ppe_intf
.reinit_flag
);
3337 len
+= sprintf(page
+ off
+ len
, " is_bad_cw = %u\n", adsl_ppe_intf
.is_bad_cw
);
3338 len
+= sprintf(page
+ off
+ len
, "\n");
3341 len
+= sprintf(page
+ off
+ len
, "Retx Firmware Context:\n");
3342 len
+= sprintf(page
+ off
+ len
, " next_dtu_sid_out (0x%08x) = 0x%02x [%3u]\n", (unsigned int )NEXT_DTU_SID_OUT
, next_dtu_sid_out
, next_dtu_sid_out
);
3343 len
+= sprintf(page
+ off
+ len
, " last_dtu_sid_in (0x%08x) = 0x%02x [%3u]\n", (unsigned int )LAST_DTU_SID_IN
, last_dtu_sid_in
, last_dtu_sid_in
);
3344 len
+= sprintf(page
+ off
+ len
, " next_cell_sid_out (0x%08x) = %u\n", (unsigned int )NEXT_CELL_SID_OUT
, next_cell_sid_out
);
3345 len
+= sprintf(page
+ off
+ len
, " isr_cell_id (0x%08x) = %u\n", (unsigned int )ISR_CELL_ID
, isr_cell_id
);
3346 len
+= sprintf(page
+ off
+ len
, " pb_cell_search_idx (0x%08x) = %u\n", (unsigned int )PB_CELL_SEARCH_IDX
, *PB_CELL_SEARCH_IDX
);
3347 len
+= sprintf(page
+ off
+ len
, " pb_read_pend_flag (0x%08x) = %u\n", (unsigned int )PB_READ_PEND_FLAG
, *PB_READ_PEND_FLAG
);
3348 len
+= sprintf(page
+ off
+ len
, " rfbi_first_cw (0x%08x) = %u\n", (unsigned int )RFBI_FIRST_CW
, *RFBI_FIRST_CW
);
3349 len
+= sprintf(page
+ off
+ len
, " rfbi_bad_cw (0x%08x) = %u\n", (unsigned int )RFBI_BAD_CW
, *RFBI_BAD_CW
);
3350 len
+= sprintf(page
+ off
+ len
, " rfbi_invalid_cw (0x%08x) = %u\n", (unsigned int )RFBI_INVALID_CW
, *RFBI_INVALID_CW
);
3351 len
+= sprintf(page
+ off
+ len
, " rfbi_retx_cw (0x%08x) = %u\n", (unsigned int )RFBI_RETX_CW
, *RFBI_RETX_CW
);
3352 len
+= sprintf(page
+ off
+ len
, " rfbi_chk_dtu_status (0x%08x) = %u\n", (unsigned int )RFBI_CHK_DTU_STATUS
,*RFBI_CHK_DTU_STATUS
);
3353 len
+= sprintf(page
+ off
+ len
, "\n");
3356 len
+= sprintf(page
+ off
+ len
, "SFSM Status: bc0 bc1 \n\n");
3357 len
+= sprintf(page
+ off
+ len
, " state = %-22s , %s\n",
3358 (*__WRXCTXT_PortState(0) & 3) == 0 ? "Hunt" :
3359 (*__WRXCTXT_PortState(0) & 3) == 1 ? "Pre_sync" :
3360 (*__WRXCTXT_PortState(0) & 3) == 2 ? "Sync" :
3362 (*__WRXCTXT_PortState(1) & 3) == 0 ? "Hunt" :
3363 (*__WRXCTXT_PortState(1) & 3) == 1 ? "Pre_sync" :
3364 (*__WRXCTXT_PortState(1) & 3) == 2 ? "Sync" :
3366 len
+= sprintf(page
+ off
+ len
, " dbase = 0x%04x ( 0x%08x ) , 0x%04x ( 0x%08x )\n",
3367 SFSM_DBA(0)->dbase
, (unsigned int)PPM_INT_UNIT_ADDR(SFSM_DBA(0)->dbase
+ 0x2000),
3368 SFSM_DBA(1)->dbase
, (unsigned int)PPM_INT_UNIT_ADDR(SFSM_DBA(1)->dbase
+ 0x2000));
3369 len
+= sprintf(page
+ off
+ len
, " cbase = 0x%04x ( 0x%08x ) , 0x%04x ( 0x%08x )\n",
3370 SFSM_CBA(0)->cbase
, (unsigned int)PPM_INT_UNIT_ADDR(SFSM_CBA(0)->cbase
+ 0x2000),
3371 SFSM_CBA(1)->cbase
, (unsigned int)PPM_INT_UNIT_ADDR(SFSM_CBA(1)->cbase
+ 0x2000));
3372 len
+= sprintf(page
+ off
+ len
, " sen = %-22d , %d\n", SFSM_CFG(0)->sen
, SFSM_CFG(1)->sen
);
3373 len
+= sprintf(page
+ off
+ len
, " idlekeep = %-22d , %d\n", SFSM_CFG(0)->idlekeep
, SFSM_CFG(1)->idlekeep
);
3374 len
+= sprintf(page
+ off
+ len
, " pnum = %-22d , %d\n", SFSM_CFG(0)->pnum
, SFSM_CFG(1)->pnum
);
3375 len
+= sprintf(page
+ off
+ len
, " pptr = %-22d , %d\n", SFSM_PGCNT(0)->pptr
, SFSM_PGCNT(1)->pptr
);
3376 len
+= sprintf(page
+ off
+ len
, " upage = %-22d , %d\n", SFSM_PGCNT(0)->upage
, SFSM_PGCNT(1)->upage
);
3377 len
+= sprintf(page
+ off
+ len
, " l2_rdptr = %-22d , %d\n", *__WRXCTXT_L2_RdPtr(0), *__WRXCTXT_L2_RdPtr(1) );
3378 len
+= sprintf(page
+ off
+ len
, " l2_page = %-22d , %d\n", *__WRXCTXT_L2Pages(0), *__WRXCTXT_L2Pages(1) );
3379 len
+= sprintf(page
+ off
+ len
, "\n");
3382 len
+= sprintf(page
+ off
+ len
, "FFSM Status: bc0 bc1 \n\n");
3383 len
+= sprintf(page
+ off
+ len
, " dbase = 0x%04x ( 0x%08x ) , 0x%04x ( 0x%08x )\n",
3384 FFSM_DBA(0)->dbase
, (unsigned int)PPM_INT_UNIT_ADDR(FFSM_DBA(0)->dbase
+ 0x2000),
3385 FFSM_DBA(1)->dbase
, (unsigned int)PPM_INT_UNIT_ADDR(FFSM_DBA(1)->dbase
+ 0x2000));
3386 len
+= sprintf(page
+ off
+ len
, " pnum = %-22d , %d\n", FFSM_CFG(0)->pnum
, FFSM_CFG(1)->pnum
);
3387 len
+= sprintf(page
+ off
+ len
, " vpage = %-22d , %d\n", FFSM_PGCNT(0)->vpage
, FFSM_PGCNT(1)->vpage
);
3388 len
+= sprintf(page
+ off
+ len
, " ival = %-22d , %d\n", FFSM_PGCNT(0)->ival
, FFSM_PGCNT(1)->ival
);
3389 len
+= sprintf(page
+ off
+ len
, " tc_wrptr = %-22d , %d\n", *__WTXCTXT_TC_WRPTR(0), *__WTXCTXT_TC_WRPTR(1));
3390 len
+= sprintf(page
+ off
+ len
, "\n");
3393 len
+= sprintf(page
+ off
+ len
, "Misc: \n\n");
3394 len
+= sprintf(page
+ off
+ len
, " curr_time = %08x\n", curr_time
);
3395 len
+= sprintf(page
+ off
+ len
, " sec_counter = %d\n", sec_counter
);
3396 len
+= sprintf(page
+ off
+ len
, " curr_efb = %d\n", curr_efb
);
3397 len
+= sprintf(page
+ off
+ len
, "\n");
3404 static inline int is_valid(unsigned int * dtu_vld_stat
, int dtu_sid
)
3406 int dw_idx
= (dtu_sid
/ 32) & 7;
3407 int bit_pos
= dtu_sid
% 32;
3409 return dtu_vld_stat
[dw_idx
] & (0x80000000 >> bit_pos
);
3412 static int proc_read_retx_stats(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3416 int len_max
= off
+ count
;
3421 unsigned int next_dtu_sid_out
, last_dtu_sid_in
, next_cell_sid_out
;
3422 unsigned int dtu_vld_stat
[8];
3423 struct DTU_stat_info dtu_stat_info
[256];
3424 struct Retx_adsl_ppe_intf adsl_ppe_intf
;
3426 pstr
= *start
= page
;
3430 // capture a snapshot of internal status
3431 next_dtu_sid_out
= *NEXT_DTU_SID_OUT
;
3432 last_dtu_sid_in
= *LAST_DTU_SID_IN
;
3433 next_cell_sid_out
= *NEXT_CELL_SID_OUT
;
3434 adsl_ppe_intf
= *RETX_ADSL_PPE_INTF
;
3436 memcpy(&dtu_vld_stat
, (void *)DTU_VLD_STAT
, sizeof(dtu_vld_stat
));
3437 memcpy(&dtu_stat_info
, (void *)DTU_STAT_INFO
, sizeof(dtu_stat_info
));
3440 llen
+= sprintf(str
+ llen
, "Adsl-PPE Interface:\n");
3441 llen
+= sprintf(str
+ llen
, " dtu_sid = 0x%02x [%3u]\n", adsl_ppe_intf
.dtu_sid
, adsl_ppe_intf
.dtu_sid
);
3442 llen
+= sprintf(str
+ llen
, " dtu_timestamp = 0x%02x\n", adsl_ppe_intf
.dtu_timestamp
);
3443 llen
+= sprintf(str
+ llen
, " local_time = 0x%02x\n", adsl_ppe_intf
.local_time
);
3444 llen
+= sprintf(str
+ llen
, " is_last_cw = %u\n", adsl_ppe_intf
.is_last_cw
);
3445 llen
+= sprintf(str
+ llen
, " reinit_flag = %u\n", adsl_ppe_intf
.reinit_flag
);
3446 llen
+= sprintf(str
+ llen
, " is_bad_cw = %u\n", adsl_ppe_intf
.is_bad_cw
);
3447 llen
+= sprintf(str
+ llen
, "\n");
3449 llen
+= sprintf(str
+ llen
, "Retx Internal State:\n");
3450 llen
+= sprintf(str
+ llen
, " next_dtu_sid_out (0x%08x) = 0x%02x [%3u]\n", (unsigned int )NEXT_DTU_SID_OUT
, next_dtu_sid_out
, next_dtu_sid_out
);
3451 llen
+= sprintf(str
+ llen
, " last_dtu_sid_in (0x%08x) = 0x%02x [%3u]\n", (unsigned int )LAST_DTU_SID_IN
, last_dtu_sid_in
, last_dtu_sid_in
);
3452 llen
+= sprintf(str
+ llen
, " next_cell_sid_out (0x%08x) = %u\n", (unsigned int )NEXT_CELL_SID_OUT
, next_cell_sid_out
);
3453 llen
+= sprintf(str
+ llen
, " dtu_valid_stat (0x%08x)\n", (unsigned int )DTU_VLD_STAT
);
3454 llen
+= sprintf(str
+ llen
, " dtu_stat_info (0x%08x)\n", (unsigned int )DTU_STAT_INFO
);
3455 llen
+= sprintf(str
+ llen
, " pb_buffer_usage (0x%08x)\n", (unsigned int )PB_BUFFER_USAGE
);
3457 if ( len
<= off
&& len
+ llen
> off
) {
3458 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3459 pstr
+= len
+ llen
- off
;
3461 else if ( len
> off
) {
3462 memcpy(pstr
, str
, llen
);
3466 if ( len
>= len_max
)
3467 goto PROC_READ_RETX_STATS_OVERRUN_END
;
3471 llen
+= sprintf(str
+ llen
, "\n");
3472 llen
+= sprintf(str
+ llen
, "DTU_VALID_STAT: [0x%08x]:\n", (unsigned int)DTU_VLD_STAT
);
3473 llen
+= sprintf(str
+ llen
, "%08X: %08X %08X %08X %08X %08X %08X %08X %08X\n",
3474 (unsigned int)DTU_VLD_STAT
,
3475 dtu_vld_stat
[0], dtu_vld_stat
[1], dtu_vld_stat
[2], dtu_vld_stat
[3],
3476 dtu_vld_stat
[4], dtu_vld_stat
[5], dtu_vld_stat
[6], dtu_vld_stat
[7]);
3478 if ( len
<= off
&& len
+ llen
> off
) {
3479 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3480 pstr
+= len
+ llen
- off
;
3482 else if ( len
> off
) {
3483 memcpy(pstr
, str
, llen
);
3487 if ( len
>= len_max
)
3488 goto PROC_READ_RETX_STATS_OVERRUN_END
;
3492 llen
+= sprintf(str
+ llen
, "\n");
3493 llen
+= sprintf(str
+ llen
, "DTU_STAT_INFO: [0x%08x]:\n", (unsigned int)DTU_STAT_INFO
);
3494 llen
+= sprintf(str
+ llen
, "dtu_id ts complete bad cell_cnt dtu_rd_ptr dtu_wr_ptr\n");
3495 llen
+= sprintf(str
+ llen
, "---------------------------------------------------------------------\n");
3496 for ( i
= 0; i
< 256; i
++ ) {
3497 if ( !is_valid(dtu_vld_stat
, i
) )
3500 llen
+= sprintf(str
+ llen
, "0x%02x [%3u] 0x%02x %d %d %3d %5d %5d\n",
3502 DTU_STAT_INFO
[i
].time_stamp
,
3503 DTU_STAT_INFO
[i
].complete
,
3504 DTU_STAT_INFO
[i
].bad
,
3505 DTU_STAT_INFO
[i
].cell_cnt
,
3506 DTU_STAT_INFO
[i
].dtu_rd_ptr
,
3507 DTU_STAT_INFO
[i
].dtu_wr_ptr
);
3509 if ( len
<= off
&& len
+ llen
> off
) {
3510 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3511 pstr
+= len
+ llen
- off
;
3513 else if ( len
> off
)
3515 memcpy(pstr
, str
, llen
);
3519 if ( len
>= len_max
)
3520 goto PROC_READ_RETX_STATS_OVERRUN_END
;
3525 llen
+= sprintf(str
+ llen
, "\n");
3526 llen
+= sprintf(str
+ llen
, "Playout buffer status --- valid status [0x%08x]:\n", (unsigned int)PB_BUFFER_USAGE
);
3527 for( i
= 0; i
< RETX_MODE_CFG
->buff_size
; i
+= 8 ) {
3528 llen
+= sprintf(str
+ llen
, "%08X: %08X %08X %08X %08X %08X %08X %08X %08X\n",
3529 (unsigned int)PB_BUFFER_USAGE
+ i
* sizeof(unsigned int),
3530 PB_BUFFER_USAGE
[i
], PB_BUFFER_USAGE
[i
+1], PB_BUFFER_USAGE
[i
+2], PB_BUFFER_USAGE
[i
+3],
3531 PB_BUFFER_USAGE
[i
+4], PB_BUFFER_USAGE
[i
+5], PB_BUFFER_USAGE
[i
+6], PB_BUFFER_USAGE
[i
+7]);
3534 if ( len
<= off
&& len
+ llen
> off
) {
3535 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3536 pstr
+= len
+ llen
- off
;
3538 else if ( len
> off
) {
3539 memcpy(pstr
, str
, llen
);
3543 if ( len
>= len_max
)
3544 goto PROC_READ_RETX_STATS_OVERRUN_END
;
3552 PROC_READ_RETX_STATS_OVERRUN_END
:
3553 return len
- llen
- off
;
3556 static int proc_write_retx_stats(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
3563 len
= count
< sizeof(str
) ? count
: sizeof(str
) - 1;
3564 rlen
= len
- copy_from_user(str
, buf
, len
);
3565 while ( rlen
&& str
[rlen
- 1] <= ' ' )
3568 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
3572 if ( stricmp(p
, "help") == 0 ) {
3573 printk("echo clear_pb > /proc/driver/ifx_atm/retx_stats \n");
3574 printk(" :clear context in playout buffer\n\n");
3575 printk("echo read_pb <pb_index> <cell_num> > /proc/driver/ifx_atm/retx_stats\n");
3576 printk(" : read playout buffer contents\n\n");
3577 printk("echo read_[r|t]x_cb > /proc/driver/ifx_atm/retx_stats\n");
3578 printk(" : read cell buffer\n\n");
3579 printk("echo clear_[r|t]x_cb > /proc/driver/ifx_atm/retx_stats\n");
3580 printk(" : clear cell buffer\n\n");
3581 printk("echo read_bad_dtu_intf_rec > /proc/driver/ifx_atm/retx_stats\n");
3582 printk(" : read bad dtu intrface information record\n\n");
3583 printk("echo clear_bad_dtu_intf_rec > /proc/driver/ifx_atm/retx_stats\n");
3584 printk(" : clear bad dtu interface information record\n\n");
3585 printk("echo read_wrx_context [i] > /proc/driver/ifx_atm/retx_stats\n");
3586 printk(" : clear bad dtu interface information record\n\n");
3587 printk("echo read_intf_rec > /proc/driver/ifx_atm/retx_stats\n");
3588 printk(" : read interface info record buffer\n\n");
3589 printk("echo reinit_intf_rec > /proc/driver/ifx_atm/retx_stats\n");
3590 printk(" : reinit intf record, must be called before showtime\n\n");
3592 else if ( stricmp(p
, "reinit_intf_rec") == 0 ) {
3594 struct Retx_adsl_ppe_intf_rec rec
[16];
3596 *DBG_DTU_INTF_WRPTR
= 0;
3597 *DBG_INTF_FCW_DUP_CNT
= 0;
3598 *DBG_INTF_SID_CHANGE_IN_DTU_CNT
= 0;
3599 *DBG_INTF_LCW_DUP_CNT
= 0;
3601 *DBG_RFBI_DONE_INT_CNT
= 0;
3602 *DBG_RFBI_INTV0
= 0;
3603 *DBG_RFBI_INTV1
= 0;
3604 *DBG_RFBI_BC0_INVALID_CNT
= 0;
3605 *DBG_RFBI_LAST_T
= 0;
3606 *DBG_DREG_BEG_END
= 0;
3608 memset((void *) DBG_INTF_INFO(0), 0, sizeof(rec
));
3609 for( i
= 0; i
< 16; i
++ )
3610 DBG_INTF_INFO(i
)->res1_1
= 1;
3611 DBG_INTF_INFO(15)->dtu_sid
= 255;
3613 else if ( stricmp(p
, "read_intf_rec") == 0 ) {
3615 unsigned int dtu_intf_wrptr
, fcw_dup_cnt
, sid_change_in_dtu_cnt
, lcw_dup_cnt
;
3616 unsigned int rfbi_done_int_cnt
, rfbi_intv0
, rfbi_intv1
, rfbi_bc0_invalid_cnt
, dreg_beg_end
;
3617 struct Retx_adsl_ppe_intf_rec rec
[16];
3619 memcpy((void *) rec
, (void *) DBG_INTF_INFO(0), sizeof(rec
));
3621 dtu_intf_wrptr
= *DBG_DTU_INTF_WRPTR
;
3622 fcw_dup_cnt
= *DBG_INTF_FCW_DUP_CNT
;
3623 sid_change_in_dtu_cnt
= *DBG_INTF_SID_CHANGE_IN_DTU_CNT
;
3624 lcw_dup_cnt
= *DBG_INTF_LCW_DUP_CNT
;
3626 rfbi_done_int_cnt
= *DBG_RFBI_DONE_INT_CNT
;
3627 rfbi_intv0
= *DBG_RFBI_INTV0
;
3628 rfbi_intv1
= *DBG_RFBI_INTV1
;
3629 rfbi_bc0_invalid_cnt
= *DBG_RFBI_BC0_INVALID_CNT
;
3630 dreg_beg_end
= *DBG_DREG_BEG_END
;
3632 printk("PPE-Adsl Interface recrod [addr 0x23F0]:\n\n");
3634 printk(" rfbi_done_int_cnt = %d [0x%x] \n", rfbi_done_int_cnt
, rfbi_done_int_cnt
);
3635 printk(" rfbi_intv = 0x%08x 0x%08x [%d, %d, %d, %d, %d, %d, %d, %d]\n",
3636 rfbi_intv0
, rfbi_intv1
,
3637 rfbi_intv0
>> 24, (rfbi_intv0
>>16) & 0xff, (rfbi_intv0
>>8) & 0xff, rfbi_intv0
& 0xff,
3638 rfbi_intv1
>> 24, (rfbi_intv1
>>16) & 0xff, (rfbi_intv1
>>8) & 0xff, rfbi_intv1
& 0xff
3640 printk(" rfbi_bc0_invld_cnt = %d\n", rfbi_bc0_invalid_cnt
);
3641 printk(" dreg_beg_end = %d, %d\n\n", dreg_beg_end
>> 16, dreg_beg_end
& 0xffff);
3643 printk(" wrptr = %d [0x%x] \n", dtu_intf_wrptr
, dtu_intf_wrptr
);
3644 printk(" fcw_dup_cnt = %d\n", fcw_dup_cnt
);
3645 printk(" sid_chg_cnt = %d\n", sid_change_in_dtu_cnt
);
3646 printk(" lcw_dup_cnt = %d\n\n", lcw_dup_cnt
);
3649 printk(" idx itf_dw0 itf_dw1 dtu_sid timestamp local_time res1 last_cw bad_flag reinit\n");
3650 printk(" -------------------------------------------------------------------------------------\n");
3651 for ( i
= (dtu_intf_wrptr
+ 1) % 16, cnt
= 0; cnt
< 16; cnt
++, i
= (i
+ 1) % 16 ) {
3656 printk("%3d %04x %04x %3d[%02x] %3d[%02x] %3d[%02x] 0x%02x %d %d %d\n",
3658 (*(unsigned int *)&rec
[i
]) & 0xffff,
3659 (*(unsigned int *)&rec
[i
]) >> 16,
3660 rec
[i
].dtu_sid
, rec
[i
].dtu_sid
,
3661 rec
[i
].dtu_timestamp
, rec
[i
].dtu_timestamp
,
3662 rec
[i
].local_time
, rec
[i
].local_time
,
3666 rec
[i
].reinit_flag
);
3669 else if ( stricmp(p
, "read_wrx_context") == 0 ) {
3672 for( i
= 0; i
< 8; ++i
) {
3673 if ( !WRX_QUEUE_CONTEXT(i
)->curr_des0
|| !WRX_QUEUE_CONTEXT(i
)->curr_des1
)
3677 printk("WRX queue context [ %d ]: \n", i
);
3678 printk(" curr_len = %4d, mfs = %d, ec = %d, clp1 = %d, aal5dp = %d\n",
3679 WRX_QUEUE_CONTEXT(i
)->curr_len
, WRX_QUEUE_CONTEXT(i
)->mfs
,
3680 WRX_QUEUE_CONTEXT(i
)->ec
, WRX_QUEUE_CONTEXT(i
)->clp1
,
3681 WRX_QUEUE_CONTEXT(i
)->aal5dp
);
3682 printk(" initcrc = %08x\n", WRX_QUEUE_CONTEXT(i
)->intcrc
);
3683 printk(" currdes = %08x %08x\n",
3684 WRX_QUEUE_CONTEXT(i
)->curr_des0
, WRX_QUEUE_CONTEXT(i
)->curr_des1
);
3685 printk(" last_dw = %08x\n\n", WRX_QUEUE_CONTEXT(i
)->last_dword
);
3686 if( WRX_QUEUE_CONTEXT(i
)->curr_len
) {
3688 unsigned char *p_char
;
3689 struct rx_descriptor
*desc
= (struct rx_descriptor
*)&(WRX_QUEUE_CONTEXT(i
)->curr_des0
);
3690 p_char
= (unsigned char *)(((unsigned int)desc
->dataptr
<< 2) | KSEG1
);
3691 printk(" Data in SDRAM:\n ");
3693 for ( j
= 0 ; j
< WRX_QUEUE_CONTEXT(i
)->curr_len
; ++j
) {
3694 printk ("%02x", p_char
[j
]);
3697 else if ( j
% 4 == 3 )
3704 printk("No active wrx queue context\n");
3707 else if ( stricmp(p
, "clear_pb") == 0 ) {
3708 if ( g_retx_playout_buffer
)
3709 memset((void *)g_retx_playout_buffer
, 0, RETX_PLAYOUT_BUFFER_SIZE
);
3711 else if ( stricmp(p
, "read_bad_dtu_intf_rec") == 0 ) {
3712 struct Retx_adsl_ppe_intf first_dtu_intf
, last_dtu_intf
;
3713 first_dtu_intf
= *FIRST_BAD_REC_RETX_ADSL_PPE_INTF
;
3714 last_dtu_intf
= *BAD_REC_RETX_ADSL_PPE_INTF
;
3716 printk("\nAdsl-PPE Interface for first and last DTU of recent noise:\n\n");
3717 printk(" dtu_sid = 0x%02x [%3u], 0x%02x [%3u]\n",
3718 first_dtu_intf
.dtu_sid
, first_dtu_intf
.dtu_sid
,
3719 last_dtu_intf
.dtu_sid
, last_dtu_intf
.dtu_sid
);
3720 printk(" dtu_timestamp = 0x%02x , 0x%02x\n",
3721 first_dtu_intf
.dtu_timestamp
, last_dtu_intf
.dtu_timestamp
);
3722 printk(" local_time = 0x%02x , 0x%02x\n",
3723 first_dtu_intf
.local_time
, last_dtu_intf
.local_time
);
3724 printk(" is_last_cw = %u , %u\n",
3725 first_dtu_intf
.is_last_cw
, last_dtu_intf
.is_last_cw
);
3726 printk(" reinit_flag = %u , %u\n",
3727 first_dtu_intf
.reinit_flag
, last_dtu_intf
.reinit_flag
);
3728 printk(" is_bad_cw = %u , %u\n\n",
3729 first_dtu_intf
.is_bad_cw
, last_dtu_intf
.is_bad_cw
);
3731 else if ( stricmp(p
, "clear_bad_dtu_intf_rec") == 0 ) {
3732 memset((void *)BAD_REC_RETX_ADSL_PPE_INTF
, 0, sizeof(struct Retx_adsl_ppe_intf
));
3733 memset((void *)FIRST_BAD_REC_RETX_ADSL_PPE_INTF
, 0, sizeof(struct Retx_adsl_ppe_intf
));
3735 else if ( stricmp(p
, "clear_tx_cb") == 0 ) {
3736 unsigned int *dbase0
;
3739 dbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( FFSM_DBA(0)->dbase
+ 0x2000);
3740 pnum0
= FFSM_CFG(0)->pnum
;
3741 memset(dbase0
, 0, 14 * sizeof(unsigned int ) * pnum0
);
3743 else if ( stricmp(p
, "clear_rx_cb") == 0 ) {
3744 unsigned int *dbase0
, *cbase0
, *dbase1
, *cbase1
;
3747 dbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_DBA(0)->dbase
+ 0x2000);
3748 cbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_CBA(0)->cbase
+ 0x2000);
3750 dbase1
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_DBA(1)->dbase
+ 0x2000);
3751 cbase1
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_CBA(1)->cbase
+ 0x2000);
3753 pnum0
= SFSM_CFG(0)->pnum
;
3755 memset(dbase0
, 0, 14 * sizeof(unsigned int ) * pnum0
);
3756 memset(cbase0
, 0, sizeof(unsigned int ) * pnum0
);
3758 memset(dbase1
, 0, 14 * sizeof(unsigned int ));
3759 memset(cbase1
, 0, sizeof(unsigned int ));
3761 else if ( strnicmp(p
, "read_tx_cb", 10) == 0 ) {
3762 unsigned int *dbase0
;
3763 unsigned int pnum0
, i
;
3764 unsigned int * cell
;
3766 dbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( FFSM_DBA(0)->dbase
+ 0x2000);
3767 pnum0
= FFSM_CFG(0)->pnum
;
3769 printk("ATM TX BC 0 CELL data/ctrl buffer:\n\n");
3770 for(i
= 0; i
< pnum0
; ++ i
) {
3771 cell
= dbase0
+ i
* 14;
3772 printk("cell %2d: %08x %08x\n", i
, cell
[0], cell
[1]);
3773 printk(" %08x %08x %08x %08x\n", cell
[2], cell
[3], cell
[4], cell
[5]);
3774 printk(" %08x %08x %08x %08x\n", cell
[6], cell
[7], cell
[8], cell
[9]);
3775 printk(" %08x %08x %08x %08x\n", cell
[10], cell
[11], cell
[12], cell
[13]);
3778 else if ( strnicmp(p
, "read_rx_cb", 10) == 0 ) {
3779 unsigned int *dbase0
, *cbase0
, *dbase1
, *cbase1
;
3780 unsigned int pnum0
, i
;
3781 unsigned int * cell
;
3783 dbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_DBA(0)->dbase
+ 0x2000);
3784 cbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_CBA(0)->cbase
+ 0x2000);
3786 dbase1
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_DBA(1)->dbase
+ 0x2000);
3787 cbase1
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_CBA(1)->cbase
+ 0x2000);
3789 pnum0
= SFSM_CFG(0)->pnum
;
3791 printk("ATM RX BC 0 CELL data/ctrl buffer:\n\n");
3792 for(i
= 0; i
< pnum0
; ++ i
) {
3793 struct Retx_ctrl_field
* p_ctrl
;
3795 cell
= dbase0
+ i
* 14;
3796 p_ctrl
= (struct Retx_ctrl_field
*) ( &cbase0
[i
]);
3797 printk("cell %2d: %08x %08x -- [%08x]:", i
, cell
[0], cell
[1], cbase0
[i
]);
3799 printk("l2_drop: %d, retx: %d", p_ctrl
->l2_drop
, p_ctrl
->retx
);
3800 if ( p_ctrl
->retx
) {
3801 printk(", dtu_sid = %u, cell_sid = %u", p_ctrl
->dtu_sid
, p_ctrl
->cell_sid
);
3806 printk(" %08x %08x %08x %08x\n", cell
[2], cell
[3], cell
[4], cell
[5]);
3807 printk(" %08x %08x %08x %08x\n", cell
[6], cell
[7], cell
[8], cell
[9]);
3808 printk(" %08x %08x %08x %08x\n", cell
[10], cell
[11], cell
[12], cell
[13]);
3812 printk("ATM RX BC 1 CELL data/ctrl buffer:\n\n");
3814 printk("cell %2d: %08x %08x -- [%08x]: dtu_sid:%3d, cell_sid:%3d, next_ptr: %4d\n",
3815 0, cell
[0], cell
[1], cbase0
[i
], ( cell
[1] >> 16) & 0xff, (cell
[1] >> 24) & 0xff, cell
[1] & 0xffff );
3816 printk(" %08x %08x %08x %08x\n", cell
[2], cell
[3], cell
[4], cell
[5]);
3817 printk(" %08x %08x %08x %08x\n", cell
[6], cell
[7], cell
[8], cell
[9]);
3818 printk(" %08x %08x %08x %08x\n", cell
[10], cell
[11], cell
[12], cell
[13]);
3820 else if ( strnicmp(p
, "read_pb ", 8) == 0 )
3822 int start_cell_idx
= 0;
3825 unsigned int pb_buff_size
= RETX_MODE_CFG
->buff_size
* 32;
3829 ignore_space(&p
, &rlen
);
3831 start_cell_idx
= get_number(&p
, &rlen
, 0);
3832 ignore_space(&p
, &rlen
);
3833 cell_num
= get_number(&p
, &rlen
, 0);
3835 if ( start_cell_idx
>= pb_buff_size
) {
3836 printk(" Invalid cell index\n");
3843 if ( cell_num
+ start_cell_idx
> pb_buff_size
)
3844 cell_num
= pb_buff_size
- start_cell_idx
;
3846 for ( i
= 0; i
< cell_num
; ++i
) {
3847 cell
= (unsigned int *)((unsigned int *)g_retx_playout_buffer
+ (14 * (start_cell_idx
+ i
)));
3848 printk("cell %4d: %08x %08x [next_ptr = %4u, dtu_sid = %3u, cell_sid = %3u]\n",
3849 start_cell_idx
+ i
, cell
[0], cell
[1], cell
[1] & 0xffff, (cell
[1] >> 16) & 0xff, (cell
[1] >> 24) & 0xff);
3850 printk(" %08x %08x %08x %08x\n", cell
[2], cell
[3], cell
[4], cell
[5]);
3851 printk(" %08x %08x %08x %08x\n", cell
[6], cell
[7], cell
[8], cell
[9]);
3852 printk(" %08x %08x %08x %08x\n", cell
[10], cell
[11], cell
[12], cell
[13]);
3860 static int proc_read_retx_cfg(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3864 len
+= sprintf(page
+ off
+ len
, "ReTX FW Config:\n");
3865 len
+= sprintf(page
+ off
+ len
, " RETX_MODE_CFG = 0x%08x, invld_range=%u, buff_size=%u, retx=%u\n", *(volatile unsigned int *)RETX_MODE_CFG
, (unsigned int)RETX_MODE_CFG
->invld_range
, (unsigned int)RETX_MODE_CFG
->buff_size
* 32, (unsigned int)RETX_MODE_CFG
->retx_en
);
3866 len
+= sprintf(page
+ off
+ len
, " RETX_TSYNC_CFG = 0x%08x, fw_alpha=%u, sync_inp=%u\n", *(volatile unsigned int *)RETX_TSYNC_CFG
, (unsigned int)RETX_TSYNC_CFG
->fw_alpha
, (unsigned int)RETX_TSYNC_CFG
->sync_inp
);
3867 len
+= sprintf(page
+ off
+ len
, " RETX_TD_CFG = 0x%08x, td_max=%u, td_min=%u\n", *(volatile unsigned int *)RETX_TD_CFG
, (unsigned int)RETX_TD_CFG
->td_max
, (unsigned int)RETX_TD_CFG
->td_min
);
3868 len
+= sprintf(page
+ off
+ len
, " RETX_PLAYOUT_BUFFER_BASE = 0x%08x\n", *RETX_PLAYOUT_BUFFER_BASE
);
3869 len
+= sprintf(page
+ off
+ len
, " RETX_SERVICE_HEADER_CFG = 0x%08x\n", *RETX_SERVICE_HEADER_CFG
);
3870 len
+= sprintf(page
+ off
+ len
, " RETX_MASK_HEADER_CFG = 0x%08x\n", *RETX_MASK_HEADER_CFG
);
3871 len
+= sprintf(page
+ off
+ len
, " RETX_MIB_TIMER_CFG = 0x%08x, tick_cycle = %d, ticks_per_sec = %d\n",
3872 *(unsigned int *)RETX_MIB_TIMER_CFG
, RETX_MIB_TIMER_CFG
->tick_cycle
, RETX_MIB_TIMER_CFG
->ticks_per_sec
);
3879 static int proc_write_retx_cfg(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
3884 char local_buf
[1024];
3885 char *tokens
[4] = {0};
3886 unsigned int token_num
= 0;
3888 len
= sizeof(local_buf
) < count
? sizeof(local_buf
) - 1 : count
;
3889 len
= len
- copy_from_user(local_buf
, buf
, len
);
3894 while ( token_num
< NUM_ENTITY(tokens
) && get_token(&p1
, &p2
, &len
, &colon
) ) {
3895 tokens
[token_num
++] = p1
;
3900 if ( token_num
> 0 ) {
3901 if ( stricmp(tokens
[0], "help") == 0 ) {
3902 printk("echo help > /proc/driver/ifx_atm/retx_cfg ==> \n\tprint this help message\n\n");
3904 printk("echo set retx <enable|disable|0|1|on|off> > /proc/driver/ifx_atm/retx_cfg\n");
3905 printk("\t:enable or disable retx feature\n\n");
3907 printk("echo set <td_max|td_min|fw_alpha|sync_inp|invld_range|buff_size> <number> > /proc/driver/ifx_atm/retx_cfg\n");
3908 printk("\t: set td_max, td_min, fw_alpha, sync_inp, invalid_range, buff_size\n\n");
3910 printk("echo set <service_header|service_mask> <hex_number> /proc/driver/ifx_atm/retx_cfg \n");
3911 printk("\t: set service_header, service_mask\n\n");
3913 else if ( stricmp(tokens
[0], "set") == 0 && token_num
>= 3 ) {
3915 if ( stricmp(tokens
[1], "retx") == 0 ) {
3916 if ( stricmp(tokens
[2], "enable") == 0 ||
3917 stricmp(tokens
[2], "on") == 0 ||
3918 stricmp(tokens
[2], "1") == 0 )
3919 RETX_MODE_CFG
->retx_en
= 1;
3920 else if ( stricmp(tokens
[2], "disable") == 0 ||
3921 stricmp(tokens
[2], "off") == 0 ||
3922 stricmp(tokens
[2], "0") == 0 )
3923 RETX_MODE_CFG
->retx_en
= 0;
3924 printk("RETX_MODE_CFG->retx_en - %d\n", RETX_MODE_CFG
->retx_en
);
3927 unsigned int dec_val
, hex_val
;
3930 dec_val
= (unsigned int)get_number(&p1
, NULL
, 0);
3932 hex_val
= (unsigned int)get_number(&p2
, NULL
, 1);
3935 if ( stricmp(tokens
[1], "service_header") == 0 ) {
3936 *RETX_SERVICE_HEADER_CFG
= hex_val
;
3937 printk("RETX_SERVICE_HEADER_CFG - 0x%08x\n", *RETX_SERVICE_HEADER_CFG
);
3939 else if ( stricmp(tokens
[1], "service_mask") == 0 ) {
3940 *RETX_MASK_HEADER_CFG
= hex_val
;
3941 printk("RETX_MASK_HEADER_CFG - 0x%08x\n", *RETX_MASK_HEADER_CFG
);
3945 if ( stricmp(tokens
[1], "td_max") == 0 ) {
3946 (unsigned int)RETX_TD_CFG
->td_max
= (dec_val
>= 0xff ? 0Xff : dec_val
);
3947 printk("RETX_TD_CFG->td_max - %d\n", RETX_TD_CFG
->td_max
);
3949 else if ( stricmp(tokens
[1], "td_min") == 0 ) {
3950 (unsigned int)RETX_TD_CFG
->td_min
= (dec_val
>= 0xff ? 0Xff : dec_val
);
3951 printk("RETX_TD_CFG->td_min - %d\n", RETX_TD_CFG
->td_min
);
3953 else if ( stricmp(tokens
[1], "fw_alpha") == 0 ) {
3954 RETX_TSYNC_CFG
->fw_alpha
= dec_val
>= 0x7FFE ? 0X7EEE : dec_val
;
3955 printk("RETX_TSYNC_CFG->fw_alpha - %d\n", RETX_TSYNC_CFG
->fw_alpha
);
3957 else if ( stricmp(tokens
[1], "sync_inp") == 0 ) {
3958 RETX_TSYNC_CFG
->sync_inp
= dec_val
>= 0x7FFE ? 0X7EEE : dec_val
;
3959 printk("RETX_TSYNC_CFG->sync_inp - %d\n", RETX_TSYNC_CFG
->sync_inp
);
3961 else if ( stricmp(tokens
[1], "invld_range") == 0 ) {
3962 RETX_MODE_CFG
->invld_range
= dec_val
>= 250 ? 250 : dec_val
;
3963 printk("RETX_MODE_CFG->invld_range - %d\n", RETX_MODE_CFG
->invld_range
);
3965 else if ( stricmp(tokens
[1], "buff_size") == 0 ) {
3966 dec_val
= (dec_val
+ 31) / 32;
3967 RETX_MODE_CFG
->buff_size
= dec_val
>= 4096 / 32 ? 4096 / 32 : dec_val
;
3968 printk("RETX_MODE_CFG->buff_size - %d\n", RETX_MODE_CFG
->buff_size
);
3979 static int proc_read_retx_dsl_param(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3983 len
+= sprintf(page
+ off
+ len
, "DSL Param [timestamp %ld.%ld]:\n", g_retx_polling_start
.tv_sec
, g_retx_polling_start
.tv_usec
);
3985 if ( g_xdata_addr
== NULL
)
3986 len
+= sprintf(page
+ off
+ len
, " DSL parameters not available !\n");
3988 volatile struct dsl_param
*p_dsl_param
= (volatile struct dsl_param
*)g_xdata_addr
;
3990 len
+= sprintf(page
+ off
+ len
, " update_flag = %u\n", p_dsl_param
->update_flag
);
3991 len
+= sprintf(page
+ off
+ len
, " MinDelayrt = %u\n", p_dsl_param
->MinDelayrt
);
3992 len
+= sprintf(page
+ off
+ len
, " MaxDelayrt = %u\n", p_dsl_param
->MaxDelayrt
);
3993 len
+= sprintf(page
+ off
+ len
, " RetxEnable = %u\n", p_dsl_param
->RetxEnable
);
3994 len
+= sprintf(page
+ off
+ len
, " ServiceSpecificReTx = %u\n", p_dsl_param
->ServiceSpecificReTx
);
3995 len
+= sprintf(page
+ off
+ len
, " ReTxPVC = 0x%08x\n", p_dsl_param
->ReTxPVC
);
3996 len
+= sprintf(page
+ off
+ len
, " RxDtuCorruptedCNT = %u\n", p_dsl_param
->RxDtuCorruptedCNT
);
3997 len
+= sprintf(page
+ off
+ len
, " RxRetxDtuUnCorrectedCNT = %u\n", p_dsl_param
->RxRetxDtuUnCorrectedCNT
);
3998 len
+= sprintf(page
+ off
+ len
, " RxLastEFB = %u\n", p_dsl_param
->RxLastEFB
);
3999 len
+= sprintf(page
+ off
+ len
, " RxDtuCorrectedCNT = %u\n", p_dsl_param
->RxDtuCorrectedCNT
);
4001 if ( g_retx_polling_end
.tv_sec
!= 0 || g_retx_polling_end
.tv_usec
!= 0 ) {
4002 unsigned long polling_time_usec
;
4004 polling_time_usec
= (g_retx_polling_end
.tv_sec
- g_retx_polling_start
.tv_sec
) * 1000000 + (g_retx_polling_end
.tv_usec
- g_retx_polling_start
.tv_usec
);
4005 len
+= sprintf(page
+ off
+ len
, "DSL Param Update Time: %lu.%03lums\n", polling_time_usec
/ 1000, polling_time_usec
% 1000);
4015 static int stricmp(const char *p1
, const char *p2
)
4019 while ( *p1
&& *p2
) {
4020 c1
= *p1
>= 'A' && *p1
<= 'Z' ? *p1
+ 'a' - 'A' : *p1
;
4021 c2
= *p2
>= 'A' && *p2
<= 'Z' ? *p2
+ 'a' - 'A' : *p2
;
4031 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
4033 static int strincmp(const char *p1
, const char *p2
, int n
)
4037 while ( n
&& *p1
&& *p2
) {
4038 c1
= *p1
>= 'A' && *p1
<= 'Z' ? *p1
+ 'a' - 'A' : *p1
;
4039 c2
= *p2
>= 'A' && *p2
<= 'Z' ? *p2
+ 'a' - 'A' : *p2
;
4047 return n
? *p1
- *p2
: c1
;
4050 static int get_token(char **p1
, char **p2
, int *len
, int *colon
)
4054 while ( *len
&& !((**p1
>= 'A' && **p1
<= 'Z') || (**p1
>= 'a' && **p1
<= 'z') || (**p1
>= '0' && **p1
<= '9')) )
4066 while ( *len
&& **p2
> ' ' && **p2
!= ',' )
4082 while ( *len
&& **p2
> ' ' && **p2
!= ',' )
4094 static unsigned int get_number(char **p
, int *len
, int is_hex
)
4096 unsigned int ret
= 0;
4099 if ( (*p
)[0] == '0' && (*p
)[1] == 'x' )
4109 while ( (!len
|| *len
) && ((**p
>= '0' && **p
<= '9') || (**p
>= 'a' && **p
<= 'f') || (**p
>= 'A' && **p
<= 'F')) )
4111 if ( **p
>= '0' && **p
<= '9' )
4113 else if ( **p
>= 'a' && **p
<= 'f' )
4115 else if ( **p
>= 'A' && **p
<= 'F' )
4117 ret
= (ret
<< 4) | n
;
4125 while ( (!len
|| *len
) && **p
>= '0' && **p
<= '9' )
4138 static void ignore_space(char **p
, int *len
)
4140 while ( *len
&& (**p
<= ' ' || **p
== ':' || **p
== '.' || **p
== ',') )
4149 static INLINE
int ifx_atm_version(char *buf
)
4152 unsigned int major
, minor
;
4154 ifx_atm_get_fw_ver(&major
, &minor
);
4156 len
+= sprintf(buf
+ len
, " ATM (A1) firmware version %d.%d.%d\n", IFX_ATM_VER_MAJOR
, IFX_ATM_VER_MID
,IFX_ATM_VER_MINOR
);
4161 static INLINE
void check_parameters(void)
4163 /* Please refer to Amazon spec 15.4 for setting these values. */
4166 if ( qsb_tstep
< 1 )
4168 else if ( qsb_tstep
> 4 )
4170 else if ( qsb_tstep
== 3 )
4173 /* There is a delay between PPE write descriptor and descriptor is */
4174 /* really stored in memory. Host also has this delay when writing */
4175 /* descriptor. So PPE will use this value to determine if the write */
4176 /* operation makes effect. */
4177 if ( write_descriptor_delay
< 0 )
4178 write_descriptor_delay
= 0;
4180 if ( aal5_fill_pattern
< 0 )
4181 aal5_fill_pattern
= 0;
4183 aal5_fill_pattern
&= 0xFF;
4185 /* Because of the limitation of length field in descriptors, the packet */
4186 /* size could not be larger than 64K minus overhead size. */
4187 if ( aal5r_max_packet_size
< 0 )
4188 aal5r_max_packet_size
= 0;
4189 else if ( aal5r_max_packet_size
>= 65535 - MAX_RX_FRAME_EXTRA_BYTES
)
4190 aal5r_max_packet_size
= 65535 - MAX_RX_FRAME_EXTRA_BYTES
;
4191 if ( aal5r_min_packet_size
< 0 )
4192 aal5r_min_packet_size
= 0;
4193 else if ( aal5r_min_packet_size
> aal5r_max_packet_size
)
4194 aal5r_min_packet_size
= aal5r_max_packet_size
;
4195 if ( aal5s_max_packet_size
< 0 )
4196 aal5s_max_packet_size
= 0;
4197 else if ( aal5s_max_packet_size
>= 65535 - MAX_TX_FRAME_EXTRA_BYTES
)
4198 aal5s_max_packet_size
= 65535 - MAX_TX_FRAME_EXTRA_BYTES
;
4199 if ( aal5s_min_packet_size
< 0 )
4200 aal5s_min_packet_size
= 0;
4201 else if ( aal5s_min_packet_size
> aal5s_max_packet_size
)
4202 aal5s_min_packet_size
= aal5s_max_packet_size
;
4204 if ( dma_rx_descriptor_length
< 2 )
4205 dma_rx_descriptor_length
= 2;
4206 if ( dma_tx_descriptor_length
< 2 )
4207 dma_tx_descriptor_length
= 2;
4208 if ( dma_rx_clp1_descriptor_threshold
< 0 )
4209 dma_rx_clp1_descriptor_threshold
= 0;
4210 else if ( dma_rx_clp1_descriptor_threshold
> dma_rx_descriptor_length
)
4211 dma_rx_clp1_descriptor_threshold
= dma_rx_descriptor_length
;
4213 if ( dma_tx_descriptor_length
< 2 )
4214 dma_tx_descriptor_length
= 2;
4217 static INLINE
int init_priv_data(void)
4221 struct rx_descriptor rx_desc
= {0};
4222 struct sk_buff
*skb
;
4223 volatile struct tx_descriptor
*p_tx_desc
;
4224 struct sk_buff
**ppskb
;
4226 // clear atm private data structure
4227 memset(&g_atm_priv_data
, 0, sizeof(g_atm_priv_data
));
4229 // allocate memory for RX (AAL) descriptors
4230 p
= kzalloc(dma_rx_descriptor_length
* sizeof(struct rx_descriptor
) + DESC_ALIGNMENT
, GFP_KERNEL
);
4233 dma_cache_wback_inv((unsigned long)p
, dma_rx_descriptor_length
* sizeof(struct rx_descriptor
) + DESC_ALIGNMENT
);
4234 g_atm_priv_data
.aal_desc_base
= p
;
4235 p
= (void *)((((unsigned int)p
+ DESC_ALIGNMENT
- 1) & ~(DESC_ALIGNMENT
- 1)) | KSEG1
);
4236 g_atm_priv_data
.aal_desc
= (volatile struct rx_descriptor
*)p
;
4238 // allocate memory for RX (OAM) descriptors
4239 p
= kzalloc(RX_DMA_CH_OAM_DESC_LEN
* sizeof(struct rx_descriptor
) + DESC_ALIGNMENT
, GFP_KERNEL
);
4242 dma_cache_wback_inv((unsigned long)p
, RX_DMA_CH_OAM_DESC_LEN
* sizeof(struct rx_descriptor
) + DESC_ALIGNMENT
);
4243 g_atm_priv_data
.oam_desc_base
= p
;
4244 p
= (void *)((((unsigned int)p
+ DESC_ALIGNMENT
- 1) & ~(DESC_ALIGNMENT
- 1)) | KSEG1
);
4245 g_atm_priv_data
.oam_desc
= (volatile struct rx_descriptor
*)p
;
4247 // allocate memory for RX (OAM) buffer
4248 p
= kzalloc(RX_DMA_CH_OAM_DESC_LEN
* RX_DMA_CH_OAM_BUF_SIZE
+ DATA_BUFFER_ALIGNMENT
, GFP_KERNEL
);
4251 dma_cache_wback_inv((unsigned long)p
, RX_DMA_CH_OAM_DESC_LEN
* RX_DMA_CH_OAM_BUF_SIZE
+ DATA_BUFFER_ALIGNMENT
);
4252 g_atm_priv_data
.oam_buf_base
= p
;
4253 p
= (void *)(((unsigned int)p
+ DATA_BUFFER_ALIGNMENT
- 1) & ~(DATA_BUFFER_ALIGNMENT
- 1));
4254 g_atm_priv_data
.oam_buf
= p
;
4256 // allocate memory for TX descriptors
4257 p
= kzalloc(MAX_PVC_NUMBER
* dma_tx_descriptor_length
* sizeof(struct tx_descriptor
) + DESC_ALIGNMENT
, GFP_KERNEL
);
4260 dma_cache_wback_inv((unsigned long)p
, MAX_PVC_NUMBER
* dma_tx_descriptor_length
* sizeof(struct tx_descriptor
) + DESC_ALIGNMENT
);
4261 g_atm_priv_data
.tx_desc_base
= p
;
4263 // allocate memory for TX skb pointers
4264 p
= kzalloc(MAX_PVC_NUMBER
* dma_tx_descriptor_length
* sizeof(struct sk_buff
*) + 4, GFP_KERNEL
);
4267 dma_cache_wback_inv((unsigned long)p
, MAX_PVC_NUMBER
* dma_tx_descriptor_length
* sizeof(struct sk_buff
*) + 4);
4268 g_atm_priv_data
.tx_skb_base
= p
;
4270 // setup RX (AAL) descriptors
4275 rx_desc
.byteoff
= 0;
4278 rx_desc
.datalen
= RX_DMA_CH_AAL_BUF_SIZE
;
4279 for ( i
= 0; i
< dma_rx_descriptor_length
; i
++ ) {
4280 skb
= alloc_skb_rx();
4283 rx_desc
.dataptr
= ((unsigned int)skb
->data
>> 2) & 0x0FFFFFFF;
4284 g_atm_priv_data
.aal_desc
[i
] = rx_desc
;
4287 // setup RX (OAM) descriptors
4288 p
= (void *)((unsigned int)g_atm_priv_data
.oam_buf
| KSEG1
);
4293 rx_desc
.byteoff
= 0;
4296 rx_desc
.datalen
= RX_DMA_CH_OAM_BUF_SIZE
;
4297 for ( i
= 0; i
< RX_DMA_CH_OAM_DESC_LEN
; i
++ ) {
4298 rx_desc
.dataptr
= ((unsigned int)p
>> 2) & 0x0FFFFFFF;
4299 g_atm_priv_data
.oam_desc
[i
] = rx_desc
;
4300 p
= (void *)((unsigned int)p
+ RX_DMA_CH_OAM_BUF_SIZE
);
4303 // setup TX descriptors and skb pointers
4304 p_tx_desc
= (volatile struct tx_descriptor
*)((((unsigned int)g_atm_priv_data
.tx_desc_base
+ DESC_ALIGNMENT
- 1) & ~(DESC_ALIGNMENT
- 1)) | KSEG1
);
4305 ppskb
= (struct sk_buff
**)(((unsigned int)g_atm_priv_data
.tx_skb_base
+ 3) & ~3);
4306 for ( i
= 0; i
< MAX_PVC_NUMBER
; i
++ ) {
4307 g_atm_priv_data
.conn
[i
].tx_desc
= &p_tx_desc
[i
* dma_tx_descriptor_length
];
4308 g_atm_priv_data
.conn
[i
].tx_skb
= &ppskb
[i
* dma_tx_descriptor_length
];
4311 for ( i
= 0; i
< ATM_PORT_NUMBER
; i
++ )
4312 g_atm_priv_data
.port
[i
].tx_max_cell_rate
= DEFAULT_TX_LINK_RATE
;
4317 static INLINE
void clear_priv_data(void)
4320 struct sk_buff
*skb
;
4322 for ( i
= 0; i
< MAX_PVC_NUMBER
; i
++ ) {
4323 if ( g_atm_priv_data
.conn
[i
].tx_skb
!= NULL
) {
4324 for ( j
= 0; j
< dma_tx_descriptor_length
; j
++ )
4325 if ( g_atm_priv_data
.conn
[i
].tx_skb
[j
] != NULL
)
4326 dev_kfree_skb_any(g_atm_priv_data
.conn
[i
].tx_skb
[j
]);
4330 if ( g_atm_priv_data
.tx_skb_base
!= NULL
)
4331 kfree(g_atm_priv_data
.tx_skb_base
);
4333 if ( g_atm_priv_data
.tx_desc_base
!= NULL
)
4334 kfree(g_atm_priv_data
.tx_desc_base
);
4336 if ( g_atm_priv_data
.oam_buf_base
!= NULL
)
4337 kfree(g_atm_priv_data
.oam_buf_base
);
4339 if ( g_atm_priv_data
.oam_desc_base
!= NULL
)
4340 kfree(g_atm_priv_data
.oam_desc_base
);
4342 if ( g_atm_priv_data
.aal_desc_base
!= NULL
) {
4343 for ( i
= 0; i
< dma_rx_descriptor_length
; i
++ ) {
4344 if ( g_atm_priv_data
.aal_desc
[i
].sop
|| g_atm_priv_data
.aal_desc
[i
].eop
) { // descriptor initialized
4345 skb
= get_skb_rx_pointer(g_atm_priv_data
.aal_desc
[i
].dataptr
);
4346 dev_kfree_skb_any(skb
);
4349 kfree(g_atm_priv_data
.aal_desc_base
);
4353 static INLINE
void init_rx_tables(void)
4356 struct wrx_queue_config wrx_queue_config
= {0};
4357 struct wrx_dma_channel_config wrx_dma_channel_config
= {0};
4358 struct htu_entry htu_entry
= {0};
4359 struct htu_result htu_result
= {0};
4360 struct htu_mask htu_mask
= { set
: 0x01,
4371 *CFG_WRX_HTUTS
= MAX_PVC_NUMBER
+ OAM_HTU_ENTRY_NUMBER
;
4372 #ifndef CONFIG_AMAZON_SE
4373 *CFG_WRX_QNUM
= MAX_QUEUE_NUMBER
;
4375 *CFG_WRX_DCHNUM
= RX_DMA_CH_TOTAL
;
4376 *WRX_DMACH_ON
= (1 << RX_DMA_CH_TOTAL
) - 1;
4377 *WRX_HUNT_BITTH
= DEFAULT_RX_HUNT_BITTH
;
4380 * WRX Queue Configuration Table
4382 wrx_queue_config
.uumask
= 0;
4383 wrx_queue_config
.cpimask
= 0;
4384 wrx_queue_config
.uuexp
= 0;
4385 wrx_queue_config
.cpiexp
= 0;
4386 wrx_queue_config
.mfs
= aal5r_max_packet_size
;
4387 wrx_queue_config
.oversize
= aal5r_max_packet_size
;
4388 wrx_queue_config
.undersize
= aal5r_min_packet_size
;
4389 wrx_queue_config
.errdp
= aal5r_drop_error_packet
;
4390 wrx_queue_config
.dmach
= RX_DMA_CH_AAL
;
4391 for ( i
= 0; i
< MAX_QUEUE_NUMBER
; i
++ )
4392 *WRX_QUEUE_CONFIG(i
) = wrx_queue_config
;
4393 WRX_QUEUE_CONFIG(OAM_RX_QUEUE
)->dmach
= RX_DMA_CH_OAM
;
4396 * WRX DMA Channel Configuration Table
4398 wrx_dma_channel_config
.chrl
= 0;
4399 wrx_dma_channel_config
.clp1th
= dma_rx_clp1_descriptor_threshold
;
4400 wrx_dma_channel_config
.mode
= 0;
4401 wrx_dma_channel_config
.rlcfg
= 0;
4403 wrx_dma_channel_config
.deslen
= RX_DMA_CH_OAM_DESC_LEN
;
4404 wrx_dma_channel_config
.desba
= ((unsigned int)g_atm_priv_data
.oam_desc
>> 2) & 0x0FFFFFFF;
4405 *WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_OAM
) = wrx_dma_channel_config
;
4407 wrx_dma_channel_config
.deslen
= dma_rx_descriptor_length
;
4408 wrx_dma_channel_config
.desba
= ((unsigned int)g_atm_priv_data
.aal_desc
>> 2) & 0x0FFFFFFF;
4409 *WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_AAL
) = wrx_dma_channel_config
;
4414 for ( i
= 0; i
< MAX_PVC_NUMBER
; i
++ )
4416 htu_result
.qid
= (unsigned int)i
;
4418 *HTU_ENTRY(i
+ OAM_HTU_ENTRY_NUMBER
) = htu_entry
;
4419 *HTU_MASK(i
+ OAM_HTU_ENTRY_NUMBER
) = htu_mask
;
4420 *HTU_RESULT(i
+ OAM_HTU_ENTRY_NUMBER
) = htu_result
;
4423 htu_entry
.vci
= 0x03;
4424 htu_mask
.pid_mask
= 0x03;
4425 htu_mask
.vpi_mask
= 0xFF;
4426 htu_mask
.vci_mask
= 0x0000;
4427 htu_mask
.pti_mask
= 0x07;
4428 htu_result
.cellid
= OAM_RX_QUEUE
;
4429 htu_result
.type
= 1;
4431 htu_result
.qid
= OAM_RX_QUEUE
;
4432 *HTU_RESULT(OAM_F4_SEG_HTU_ENTRY
) = htu_result
;
4433 *HTU_MASK(OAM_F4_SEG_HTU_ENTRY
) = htu_mask
;
4434 *HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY
) = htu_entry
;
4435 htu_entry
.vci
= 0x04;
4436 htu_result
.cellid
= OAM_RX_QUEUE
;
4437 htu_result
.type
= 1;
4439 htu_result
.qid
= OAM_RX_QUEUE
;
4440 *HTU_RESULT(OAM_F4_TOT_HTU_ENTRY
) = htu_result
;
4441 *HTU_MASK(OAM_F4_TOT_HTU_ENTRY
) = htu_mask
;
4442 *HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY
) = htu_entry
;
4443 htu_entry
.vci
= 0x00;
4444 htu_entry
.pti
= 0x04;
4445 htu_mask
.vci_mask
= 0xFFFF;
4446 htu_mask
.pti_mask
= 0x01;
4447 htu_result
.cellid
= OAM_RX_QUEUE
;
4448 htu_result
.type
= 1;
4450 htu_result
.qid
= OAM_RX_QUEUE
;
4451 *HTU_RESULT(OAM_F5_HTU_ENTRY
) = htu_result
;
4452 *HTU_MASK(OAM_F5_HTU_ENTRY
) = htu_mask
;
4453 *HTU_ENTRY(OAM_F5_HTU_ENTRY
) = htu_entry
;
4454 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
4455 htu_entry
.pid
= 0x0;
4456 htu_entry
.vpi
= 0x01;
4457 htu_entry
.vci
= 0x0001;
4458 htu_entry
.pti
= 0x00;
4459 htu_mask
.pid_mask
= 0x0;
4460 htu_mask
.vpi_mask
= 0x00;
4461 htu_mask
.vci_mask
= 0x0000;
4462 htu_mask
.pti_mask
= 0x3;
4463 htu_result
.cellid
= OAM_RX_QUEUE
;
4464 htu_result
.type
= 1;
4466 htu_result
.qid
= OAM_RX_QUEUE
;
4467 *HTU_RESULT(OAM_ARQ_HTU_ENTRY
) = htu_result
;
4468 *HTU_MASK(OAM_ARQ_HTU_ENTRY
) = htu_mask
;
4469 *HTU_ENTRY(OAM_ARQ_HTU_ENTRY
) = htu_entry
;
4473 static INLINE
void init_tx_tables(void)
4476 struct wtx_queue_config wtx_queue_config
= {0};
4477 struct wtx_dma_channel_config wtx_dma_channel_config
= {0};
4478 struct wtx_port_config wtx_port_config
= { res1
: 0,
4485 *CFG_WTX_DCHNUM
= MAX_TX_DMA_CHANNEL_NUMBER
;
4486 *WTX_DMACH_ON
= ((1 << MAX_TX_DMA_CHANNEL_NUMBER
) - 1) ^ ((1 << FIRST_QSB_QID
) - 1);
4487 *CFG_WRDES_DELAY
= write_descriptor_delay
;
4490 * WTX Port Configuration Table
4492 for ( i
= 0; i
< ATM_PORT_NUMBER
; i
++ )
4493 *WTX_PORT_CONFIG(i
) = wtx_port_config
;
4496 * WTX Queue Configuration Table
4498 wtx_queue_config
.qsben
= 1;
4499 wtx_queue_config
.sbid
= 0;
4500 for ( i
= 0; i
< MAX_TX_DMA_CHANNEL_NUMBER
; i
++ ) {
4501 wtx_queue_config
.qsb_vcid
= i
;
4502 *WTX_QUEUE_CONFIG(i
) = wtx_queue_config
;
4506 * WTX DMA Channel Configuration Table
4508 wtx_dma_channel_config
.mode
= 0;
4509 wtx_dma_channel_config
.deslen
= 0;
4510 wtx_dma_channel_config
.desba
= 0;
4511 for ( i
= 0; i
< FIRST_QSB_QID
; i
++ )
4512 *WTX_DMA_CHANNEL_CONFIG(i
) = wtx_dma_channel_config
;
4513 /* normal connection */
4514 wtx_dma_channel_config
.deslen
= dma_tx_descriptor_length
;
4515 for ( ; i
< MAX_TX_DMA_CHANNEL_NUMBER
; i
++ ) {
4516 wtx_dma_channel_config
.desba
= ((unsigned int)g_atm_priv_data
.conn
[i
- FIRST_QSB_QID
].tx_desc
>> 2) & 0x0FFFFFFF;
4517 *WTX_DMA_CHANNEL_CONFIG(i
) = wtx_dma_channel_config
;
4524 * ####################################
4526 * ####################################
4529 static int atm_showtime_enter(struct port_cell_info
*port_cell
, void *xdata_addr
)
4533 ASSERT(port_cell
!= NULL
, "port_cell is NULL");
4534 ASSERT(xdata_addr
!= NULL
, "xdata_addr is NULL");
4536 for ( j
= 0; j
< ATM_PORT_NUMBER
&& j
< port_cell
->port_num
; j
++ )
4537 if ( port_cell
->tx_link_rate
[j
] > 0 )
4539 for ( i
= 0; i
< ATM_PORT_NUMBER
&& i
< port_cell
->port_num
; i
++ )
4540 g_atm_priv_data
.port
[i
].tx_max_cell_rate
= port_cell
->tx_link_rate
[i
] > 0 ? port_cell
->tx_link_rate
[i
] : port_cell
->tx_link_rate
[j
];
4544 for ( i
= 0; i
< MAX_PVC_NUMBER
; i
++ )
4545 if ( g_atm_priv_data
.conn
[i
].vcc
!= NULL
)
4546 set_qsb(g_atm_priv_data
.conn
[i
].vcc
, &g_atm_priv_data
.conn
[i
].vcc
->qos
, i
);
4548 // TODO: ReTX set xdata_addr
4549 g_xdata_addr
= xdata_addr
;
4553 #if defined(CONFIG_VR9)
4554 IFX_REG_W32(0x0F, UTP_CFG
);
4557 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
4558 if ( !timer_pending(&g_retx_polling_timer
) ) {
4559 g_retx_polling_cnt
= HZ
;
4560 g_retx_polling_timer
.expires
= jiffies
+ RETX_POLLING_INTERVAL
;
4561 add_timer(&g_retx_polling_timer
);
4565 //printk("enter showtime, cell rate: 0 - %d, 1 - %d, xdata addr: 0x%08x\n", g_atm_priv_data.port[0].tx_max_cell_rate, g_atm_priv_data.port[1].tx_max_cell_rate, (unsigned int)g_xdata_addr);
4570 static int atm_showtime_exit(void)
4575 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
4576 RETX_MODE_CFG
->retx_en
= 0; // disable ReTX
4577 del_timer(&g_retx_polling_timer
);
4580 #if defined(CONFIG_VR9)
4581 IFX_REG_W32(0x00, UTP_CFG
);
4586 // TODO: ReTX clean state
4587 g_xdata_addr
= NULL
;
4589 printk("leave showtime\n");
4597 * ####################################
4599 * ####################################
4604 * Initialize global variables, PP32, comunication structures, register IRQ
4605 * and register device.
4610 * else --- failure, usually it is negative value of error code
4612 static int __devinit
ifx_atm_init(void)
4616 struct port_cell_info port_cell
= {0};
4622 ret
= init_priv_data();
4623 if ( ret
!= IFX_SUCCESS
) {
4624 err("INIT_PRIV_DATA_FAIL");
4625 goto INIT_PRIV_DATA_FAIL
;
4628 ifx_atm_init_chip();
4632 /* create devices */
4633 for ( port_num
= 0; port_num
< ATM_PORT_NUMBER
; port_num
++ ) {
4634 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
4635 g_atm_priv_data
.port
[port_num
].dev
= atm_dev_register("ifxmips_atm", &g_ifx_atm_ops
, -1, NULL
);
4637 g_atm_priv_data
.port
[port_num
].dev
= atm_dev_register("ifxmips_atm", NULL
, &g_ifx_atm_ops
, -1, NULL
);
4640 if ( !g_atm_priv_data
.port
[port_num
].dev
) {
4641 err("failed to register atm device %d!", port_num
);
4643 goto ATM_DEV_REGISTER_FAIL
;
4646 g_atm_priv_data
.port
[port_num
].dev
->ci_range
.vpi_bits
= 8;
4647 g_atm_priv_data
.port
[port_num
].dev
->ci_range
.vci_bits
= 16;
4648 g_atm_priv_data
.port
[port_num
].dev
->link_rate
= g_atm_priv_data
.port
[port_num
].tx_max_cell_rate
;
4649 g_atm_priv_data
.port
[port_num
].dev
->dev_data
= (void*)port_num
;
4653 /* register interrupt handler */
4654 ret
= request_irq(PPE_MAILBOX_IGU1_INT
, mailbox_irq_handler
, IRQF_DISABLED
, "atm_mailbox_isr", &g_atm_priv_data
);
4656 if ( ret
== -EBUSY
) {
4657 err("IRQ may be occupied by other driver, please reconfig to disable it.");
4660 err("request_irq fail");
4662 goto REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL
;
4664 disable_irq(PPE_MAILBOX_IGU1_INT
);
4666 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
4667 init_atm_tc_retrans_param();
4669 init_timer(&g_retx_polling_timer
);
4670 g_retx_polling_timer
.function
= retx_polling_func
;
4673 ret
= ifx_pp32_start(0);
4675 err("ifx_pp32_start fail!");
4676 goto PP32_START_FAIL
;
4679 port_cell
.port_num
= ATM_PORT_NUMBER
;
4680 if( !IS_ERR(&ifx_mei_atm_showtime_check
) && &ifx_mei_atm_showtime_check
)
4681 ifx_mei_atm_showtime_check(&g_showtime
, &port_cell
, &g_xdata_addr
);
4683 for ( i
= 0; i
< ATM_PORT_NUMBER
; i
++ )
4684 if ( port_cell
.tx_link_rate
[i
] != 0 )
4686 for ( j
= 0; j
< ATM_PORT_NUMBER
; j
++ )
4687 g_atm_priv_data
.port
[j
].tx_max_cell_rate
= port_cell
.tx_link_rate
[j
] != 0 ? port_cell
.tx_link_rate
[j
] : port_cell
.tx_link_rate
[i
];
4691 validate_oam_htu_entry();
4693 #if 0 /*defined(ENABLE_LED_FRAMEWORK) && ENABLE_LED_FRAMEWORK*/
4694 ifx_led_trigger_register("dsl_data", &g_data_led_trigger
);
4697 /* create proc file */
4700 if( !IS_ERR(&ifx_mei_atm_showtime_enter
) && &ifx_mei_atm_showtime_enter
)
4701 ifx_mei_atm_showtime_enter
= atm_showtime_enter
;
4703 if( !IS_ERR(&ifx_mei_atm_showtime_exit
) && !ifx_mei_atm_showtime_exit
)
4704 ifx_mei_atm_showtime_exit
= atm_showtime_exit
;
4706 ifx_atm_version(ver_str
);
4707 printk(KERN_INFO
"%s", ver_str
);
4709 printk("ifxmips_atm: ATM init succeed\n");
4714 free_irq(PPE_MAILBOX_IGU1_INT
, &g_atm_priv_data
);
4715 REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL
:
4716 ATM_DEV_REGISTER_FAIL
:
4717 while ( port_num
-- > 0 )
4718 atm_dev_deregister(g_atm_priv_data
.port
[port_num
].dev
);
4719 INIT_PRIV_DATA_FAIL
:
4721 printk("ifxmips_atm: ATM init failed\n");
4727 * Release memory, free IRQ, and deregister device.
4733 static void __exit
ifx_atm_exit(void)
4737 if( !IS_ERR(&ifx_mei_atm_showtime_enter
) && &ifx_mei_atm_showtime_enter
)
4738 ifx_mei_atm_showtime_enter
= NULL
;
4739 if( !IS_ERR(&ifx_mei_atm_showtime_exit
) && !ifx_mei_atm_showtime_exit
)
4740 ifx_mei_atm_showtime_exit
= NULL
;
4744 #if 0 /*defined(ENABLE_LED_FRAMEWORK) && ENABLE_LED_FRAMEWORK*/
4745 ifx_led_trigger_deregister(g_data_led_trigger
);
4746 g_data_led_trigger
= NULL
;
4749 invalidate_oam_htu_entry();
4753 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
4754 del_timer(&g_retx_polling_timer
);
4755 clear_atm_tc_retrans_param();
4758 free_irq(PPE_MAILBOX_IGU1_INT
, &g_atm_priv_data
);
4760 for ( port_num
= 0; port_num
< ATM_PORT_NUMBER
; port_num
++ )
4761 atm_dev_deregister(g_atm_priv_data
.port
[port_num
].dev
);
4763 ifx_atm_uninit_chip();
4768 module_init(ifx_atm_init
);
4769 module_exit(ifx_atm_exit
);
4770 MODULE_LICENSE("Dual BSD/GPL");