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>
61 * Chip Specific Head File
63 #include <lantiq_soc.h>
64 #include "ifxmips_compat.h"
66 #include "ifxmips_mei_interface.h"
67 #include "ifxmips_atm_core.h"
72 * ####################################
73 * Kernel Version Adaption
74 * ####################################
76 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
77 #define MODULE_PARM_ARRAY(a, b) module_param_array(a, int, NULL, 0)
78 #define MODULE_PARM(a, b) module_param(a, int, 0)
80 #define MODULE_PARM_ARRAY(a, b) MODULE_PARM(a, b)
86 \addtogroup IFXMIPS_ATM_MODULE_PARAMS
90 * ####################################
91 * Parameters to Configure PPE
92 * ####################################
95 \brief QSB cell delay variation due to concurrency
97 static int qsb_tau
= 1; /* QSB cell delay variation due to concurrency */
99 \brief QSB scheduler burst length
101 static int qsb_srvm
= 0x0F; /* QSB scheduler burst length */
103 \brief QSB time step, all legal values are 1, 2, 4
105 static int qsb_tstep
= 4 ; /* QSB time step, all legal values are 1, 2, 4 */
108 \brief Write descriptor delay
110 static int write_descriptor_delay
= 0x20; /* Write descriptor delay */
113 \brief AAL5 padding byte ('~')
115 static int aal5_fill_pattern
= 0x007E; /* AAL5 padding byte ('~') */
117 \brief Max frame size for RX
119 static int aal5r_max_packet_size
= 0x0700; /* Max frame size for RX */
121 \brief Min frame size for RX
123 static int aal5r_min_packet_size
= 0x0000; /* Min frame size for RX */
125 \brief Max frame size for TX
127 static int aal5s_max_packet_size
= 0x0700; /* Max frame size for TX */
129 \brief Min frame size for TX
131 static int aal5s_min_packet_size
= 0x0000; /* Min frame size for TX */
133 \brief Drop error packet in RX path
135 static int aal5r_drop_error_packet
= 1; /* Drop error packet in RX path */
138 \brief Number of descriptors per DMA RX channel
140 static int dma_rx_descriptor_length
= 128; /* Number of descriptors per DMA RX channel */
142 \brief Number of descriptors per DMA TX channel
144 static int dma_tx_descriptor_length
= 64; /* Number of descriptors per DMA TX channel */
146 \brief PPE core clock cycles between descriptor write and effectiveness in external RAM
148 static int dma_rx_clp1_descriptor_threshold
= 38;
151 MODULE_PARM(qsb_tau
, "i");
152 MODULE_PARM_DESC(qsb_tau
, "Cell delay variation. Value must be > 0");
153 MODULE_PARM(qsb_srvm
, "i");
154 MODULE_PARM_DESC(qsb_srvm
, "Maximum burst size");
155 MODULE_PARM(qsb_tstep
, "i");
156 MODULE_PARM_DESC(qsb_tstep
, "n*32 cycles per sbs cycles n=1,2,4");
158 MODULE_PARM(write_descriptor_delay
, "i");
159 MODULE_PARM_DESC(write_descriptor_delay
, "PPE core clock cycles between descriptor write and effectiveness in external RAM");
161 MODULE_PARM(aal5_fill_pattern
, "i");
162 MODULE_PARM_DESC(aal5_fill_pattern
, "Filling pattern (PAD) for AAL5 frames");
163 MODULE_PARM(aal5r_max_packet_size
, "i");
164 MODULE_PARM_DESC(aal5r_max_packet_size
, "Max packet size in byte for downstream AAL5 frames");
165 MODULE_PARM(aal5r_min_packet_size
, "i");
166 MODULE_PARM_DESC(aal5r_min_packet_size
, "Min packet size in byte for downstream AAL5 frames");
167 MODULE_PARM(aal5s_max_packet_size
, "i");
168 MODULE_PARM_DESC(aal5s_max_packet_size
, "Max packet size in byte for upstream AAL5 frames");
169 MODULE_PARM(aal5s_min_packet_size
, "i");
170 MODULE_PARM_DESC(aal5s_min_packet_size
, "Min packet size in byte for upstream AAL5 frames");
171 MODULE_PARM(aal5r_drop_error_packet
, "i");
172 MODULE_PARM_DESC(aal5r_drop_error_packet
, "Non-zero value to drop error packet for downstream");
174 MODULE_PARM(dma_rx_descriptor_length
, "i");
175 MODULE_PARM_DESC(dma_rx_descriptor_length
, "Number of descriptor assigned to DMA RX channel (>16)");
176 MODULE_PARM(dma_tx_descriptor_length
, "i");
177 MODULE_PARM_DESC(dma_tx_descriptor_length
, "Number of descriptor assigned to DMA TX channel (>16)");
178 MODULE_PARM(dma_rx_clp1_descriptor_threshold
, "i");
179 MODULE_PARM_DESC(dma_rx_clp1_descriptor_threshold
, "Descriptor threshold for cells with cell loss priority 1");
184 * ####################################
186 * ####################################
189 #define ENABLE_LED_FRAMEWORK 1
191 #define DUMP_SKB_LEN ~0
196 * ####################################
198 * ####################################
204 static int ppe_ioctl(struct atm_dev
*, unsigned int, void *);
205 static int ppe_open(struct atm_vcc
*);
206 static void ppe_close(struct atm_vcc
*);
207 static int ppe_send(struct atm_vcc
*, struct sk_buff
*);
208 static int ppe_send_oam(struct atm_vcc
*, void *, int);
209 static int ppe_change_qos(struct atm_vcc
*, struct atm_qos
*, int);
214 static INLINE
void adsl_led_flash(void);
217 * 64-bit operation used by MIB calculation
219 static INLINE
void u64_add_u32(ppe_u64_t
, unsigned int, ppe_u64_t
*);
222 * buffer manage functions
224 static INLINE
struct sk_buff
* alloc_skb_rx(void);
225 static INLINE
struct sk_buff
* alloc_skb_tx(unsigned int);
226 struct sk_buff
* atm_alloc_tx(struct atm_vcc
*, unsigned int);
227 static INLINE
void atm_free_tx_skb_vcc(struct sk_buff
*, struct atm_vcc
*);
228 static INLINE
struct sk_buff
*get_skb_rx_pointer(unsigned int);
229 static INLINE
int get_tx_desc(unsigned int);
232 * mailbox handler and signal function
234 static INLINE
void mailbox_oam_rx_handler(void);
235 static INLINE
void mailbox_aal_rx_handler(void);
236 #if defined(ENABLE_TASKLET) && ENABLE_TASKLET
237 static void do_ppe_tasklet(unsigned long);
239 static irqreturn_t
mailbox_irq_handler(int, void *);
240 static INLINE
void mailbox_signal(unsigned int, int);
243 * QSB & HTU setting functions
245 static void set_qsb(struct atm_vcc
*, struct atm_qos
*, unsigned int);
246 static void qsb_global_set(void);
247 static INLINE
void set_htu_entry(unsigned int, unsigned int, unsigned int, int, int);
248 static INLINE
void clear_htu_entry(unsigned int);
249 static void validate_oam_htu_entry(void);
250 static void invalidate_oam_htu_entry(void);
253 * look up for connection ID
255 static INLINE
int find_vpi(unsigned int);
256 static INLINE
int find_vpivci(unsigned int, unsigned int);
257 static INLINE
int find_vcc(struct atm_vcc
*);
262 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
263 static void retx_polling_func(unsigned long);
264 static int init_atm_tc_retrans_param(void);
265 static void clear_atm_tc_retrans_param(void);
272 #if defined(DEBUG_DUMP_SKB) && DEBUG_DUMP_SKB
273 static void dump_skb(struct sk_buff
*, unsigned int, char *, int, int, int);
275 #define dump_skb(skb, len, title, port, ch, is_tx) do {} while (0)
277 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
278 static void skb_swap(struct sk_buff
*, unsigned int);
280 #define skb_swap(skb, byteoff) do {} while (0)
284 * Proc File Functions
286 static INLINE
void proc_file_create(void);
287 static INLINE
void proc_file_delete(void);
288 static int proc_read_version(char *, char **, off_t
, int, int *, void *);
289 static int proc_read_mib(char *, char **, off_t
, int, int *, void *);
290 static int proc_write_mib(struct file
*, const char *, unsigned long, void *);
291 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
292 static int proc_read_retx_mib(char *, char **, off_t
, int, int *, void *);
293 static int proc_write_retx_mib(struct file
*, const char *, unsigned long, void *);
295 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
296 static int proc_read_dbg(char *, char **, off_t
, int, int *, void *);
297 static int proc_write_dbg(struct file
*, const char *, unsigned long, void *);
298 static int proc_write_mem(struct file
*, const char *, unsigned long, void *);
299 #if defined(CONFIG_AR9) || defined(CONFIG_VR9) || defined(CONFIG_DANUBE) || defined(CONFIG_AMAZON_SE)
300 static int proc_read_pp32(char *, char **, off_t
, int, int *, void *);
301 static int proc_write_pp32(struct file
*, const char *, unsigned long, void *);
304 #if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
305 static int proc_read_htu(char *, char **, off_t
, int, int *, void *);
306 static int proc_read_txq(char *, char **, off_t
, int, int *, void *);
307 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
308 static int proc_read_retx_fw(char *, char **, off_t
, int, int *, void *);
309 static int proc_read_retx_stats(char *, char **, off_t
, int, int *, void *);
310 static int proc_write_retx_stats(struct file
*, const char *, unsigned long, void *);
311 static int proc_read_retx_cfg(char *, char **, off_t
, int, int *, void *);
312 static int proc_write_retx_cfg(struct file
*, const char *, unsigned long, void *);
313 static int proc_read_retx_dsl_param(char *, char **, off_t
, int, int *, void *);
318 * Proc Help Functions
320 static int stricmp(const char *, const char *);
321 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
322 static int strincmp(const char *, const char *, int);
323 static int get_token(char **, char **, int *, int *);
324 static unsigned int get_number(char **, int *, int);
325 static void ignore_space(char **, int *);
327 static INLINE
int ifx_atm_version(char *);
330 * Init & clean-up functions
332 static INLINE
void check_parameters(void);
333 static INLINE
int init_priv_data(void);
334 static INLINE
void clear_priv_data(void);
335 static INLINE
void init_rx_tables(void);
336 static INLINE
void init_tx_tables(void);
341 #if defined(CONFIG_IFX_OAM) || defined(CONFIG_IFX_OAM_MODULE)
342 extern void ifx_push_oam(unsigned char *);
344 static inline void ifx_push_oam(unsigned char *dummy
) {}
346 #if defined(CONFIG_IFXMIPS_DSL_CPE_MEI) || defined(CONFIG_IFXMIPS_DSL_CPE_MEI_MODULE)
347 #if !defined(ENABLE_LED_FRAMEWORK) || !ENABLE_LED_FRAMEWORK
348 extern int ifx_mei_atm_led_blink(void) __attribute__ ((weak
));
350 extern int ifx_mei_atm_showtime_check(int *is_showtime
, struct port_cell_info
*port_cell
, void **xdata_addr
) __attribute__ ((weak
));
352 #if !defined(ENABLE_LED_FRAMEWORK) || !ENABLE_LED_FRAMEWORK
353 static inline int ifx_mei_atm_led_blink(void) { return IFX_SUCCESS
; }
355 static inline int ifx_mei_atm_showtime_check(int *is_showtime
, struct port_cell_info
*port_cell
, void **xdata_addr
)
357 if ( is_showtime
!= NULL
)
366 struct sk_buff
* (*ifx_atm_alloc_tx
)(struct atm_vcc
*, unsigned int) = NULL
;
369 //extern struct sk_buff* (*ifx_atm_alloc_tx)(struct atm_vcc *, unsigned int);
370 #if defined(CONFIG_IFXMIPS_DSL_CPE_MEI) || defined(CONFIG_IFXMIPS_DSL_CPE_MEI_MODULE)
371 extern int (*ifx_mei_atm_showtime_enter
)(struct port_cell_info
*, void *) __attribute__ ((weak
));
372 extern int (*ifx_mei_atm_showtime_exit
)(void) __attribute__ ((weak
));
374 int (*ifx_mei_atm_showtime_enter
)(struct port_cell_info
*, void *) = NULL
;
375 EXPORT_SYMBOL(ifx_mei_atm_showtime_enter
);
376 int (*ifx_mei_atm_showtime_exit
)(void) = NULL
;
377 EXPORT_SYMBOL(ifx_mei_atm_showtime_exit
);
383 * ####################################
385 * ####################################
388 static struct atm_priv_data g_atm_priv_data
;
390 static struct atmdev_ops g_ifx_atm_ops
= {
395 .send_oam
= ppe_send_oam
,
396 .change_qos
= ppe_change_qos
,
397 .owner
= THIS_MODULE
,
400 #if defined(ENABLE_TASKLET) && ENABLE_TASKLET
401 DECLARE_TASKLET(g_dma_tasklet
, do_ppe_tasklet
, 0);
404 static int g_showtime
= 0;
405 static void *g_xdata_addr
= NULL
;
407 #if 0 /*--- defined(ENABLE_LED_FRAMEWORK) && ENABLE_LED_FRAMEWORK ---*/
408 static void *g_data_led_trigger
= NULL
;
411 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
412 static unsigned long g_retx_playout_buffer
= 0;
414 static volatile int g_retx_htu
= 1;
415 static struct dsl_param g_dsl_param
= {0};
416 static int g_retx_polling_cnt
= HZ
;
417 static struct timeval g_retx_polling_start
= {0}, g_retx_polling_end
= {0};
418 static struct timer_list g_retx_polling_timer
;
421 unsigned int ifx_atm_dbg_enable
= 0;
423 static struct proc_dir_entry
* g_atm_dir
= NULL
;
428 * ####################################
430 * ####################################
433 static int ppe_ioctl(struct atm_dev
*dev
, unsigned int cmd
, void *arg
)
436 atm_cell_ifEntry_t mib_cell
;
437 atm_aal5_ifEntry_t mib_aal5
;
438 atm_aal5_vcc_x_t mib_vcc
;
442 if ( _IOC_TYPE(cmd
) != PPE_ATM_IOC_MAGIC
443 || _IOC_NR(cmd
) >= PPE_ATM_IOC_MAXNR
)
446 if ( _IOC_DIR(cmd
) & _IOC_READ
)
447 ret
= !access_ok(VERIFY_WRITE
, arg
, _IOC_SIZE(cmd
));
448 else if ( _IOC_DIR(cmd
) & _IOC_WRITE
)
449 ret
= !access_ok(VERIFY_READ
, arg
, _IOC_SIZE(cmd
));
455 case PPE_ATM_MIB_CELL
: /* cell level MIB */
456 /* These MIB should be read at ARC side, now put zero only. */
457 mib_cell
.ifHCInOctets_h
= 0;
458 mib_cell
.ifHCInOctets_l
= 0;
459 mib_cell
.ifHCOutOctets_h
= 0;
460 mib_cell
.ifHCOutOctets_l
= 0;
461 mib_cell
.ifInErrors
= 0;
462 mib_cell
.ifInUnknownProtos
= WAN_MIB_TABLE
->wrx_drophtu_cell
;
463 mib_cell
.ifOutErrors
= 0;
465 ret
= sizeof(mib_cell
) - copy_to_user(arg
, &mib_cell
, sizeof(mib_cell
));
468 case PPE_ATM_MIB_AAL5
: /* AAL5 MIB */
469 value
= WAN_MIB_TABLE
->wrx_total_byte
;
470 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
);
471 g_atm_priv_data
.prev_wrx_total_byte
= value
;
472 mib_aal5
.ifHCInOctets_h
= g_atm_priv_data
.wrx_total_byte
.h
;
473 mib_aal5
.ifHCInOctets_l
= g_atm_priv_data
.wrx_total_byte
.l
;
475 value
= WAN_MIB_TABLE
->wtx_total_byte
;
476 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
);
477 g_atm_priv_data
.prev_wtx_total_byte
= value
;
478 mib_aal5
.ifHCOutOctets_h
= g_atm_priv_data
.wtx_total_byte
.h
;
479 mib_aal5
.ifHCOutOctets_l
= g_atm_priv_data
.wtx_total_byte
.l
;
481 mib_aal5
.ifInUcastPkts
= g_atm_priv_data
.wrx_pdu
;
482 mib_aal5
.ifOutUcastPkts
= WAN_MIB_TABLE
->wtx_total_pdu
;
483 mib_aal5
.ifInErrors
= WAN_MIB_TABLE
->wrx_err_pdu
;
484 mib_aal5
.ifInDiscards
= WAN_MIB_TABLE
->wrx_dropdes_pdu
+ g_atm_priv_data
.wrx_drop_pdu
;
485 mib_aal5
.ifOutErros
= g_atm_priv_data
.wtx_err_pdu
;
486 mib_aal5
.ifOutDiscards
= g_atm_priv_data
.wtx_drop_pdu
;
488 ret
= sizeof(mib_aal5
) - copy_to_user(arg
, &mib_aal5
, sizeof(mib_aal5
));
491 case PPE_ATM_MIB_VCC
: /* VCC related MIB */
492 copy_from_user(&mib_vcc
, arg
, sizeof(mib_vcc
));
493 conn
= find_vpivci(mib_vcc
.vpi
, mib_vcc
.vci
);
496 mib_vcc
.mib_vcc
.aal5VccCrcErrors
= g_atm_priv_data
.conn
[conn
].aal5_vcc_crc_err
;
497 mib_vcc
.mib_vcc
.aal5VccOverSizedSDUs
= g_atm_priv_data
.conn
[conn
].aal5_vcc_oversize_sdu
;
498 mib_vcc
.mib_vcc
.aal5VccSarTimeOuts
= 0; /* no timer support */
499 ret
= sizeof(mib_vcc
) - copy_to_user(arg
, &mib_vcc
, sizeof(mib_vcc
));
512 static int ppe_open(struct atm_vcc
*vcc
)
515 short vpi
= vcc
->vpi
;
517 struct port
*port
= &g_atm_priv_data
.port
[(int)vcc
->dev
->dev_data
];
519 int f_enable_irq
= 0;
520 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
524 if ( vcc
->qos
.aal
!= ATM_AAL5
&& vcc
->qos
.aal
!= ATM_AAL0
)
525 return -EPROTONOSUPPORT
;
527 #if !defined(DISABLE_QOS_WORKAROUND) || !DISABLE_QOS_WORKAROUND
528 /* check bandwidth */
530 if (vcc
->qos
.txtp
.traffic_class
== ATM_CBR
&&
531 vcc
->qos
.txtp
.max_pcr
> (port
->tx_max_cell_rate
- port
->tx_current_cell_rate
))
533 printk("CBR set. %s, line %d returns EINVAL\n", __FUNCTION__
, __LINE__
);
537 if(vcc
->qos
.txtp
.traffic_class
== ATM_VBR_RT
&&
538 vcc
->qos
.txtp
.max_pcr
> (port
->tx_max_cell_rate
- port
->tx_current_cell_rate
))
540 printk("VBR RT set. %s, line %d returns EINVAL\n", __FUNCTION__
, __LINE__
);
545 if (vcc
->qos
.txtp
.traffic_class
== ATM_VBR_NRT
&&
546 vcc
->qos
.txtp
.scr
> (port
->tx_max_cell_rate
- port
->tx_current_cell_rate
))
548 printk("VBR NRT set. %s, line %d returns EINVAL\n", __FUNCTION__
, __LINE__
);
553 if (vcc
->qos
.txtp
.traffic_class
== ATM_UBR_PLUS
&&
554 vcc
->qos
.txtp
.min_pcr
> (port
->tx_max_cell_rate
- port
->tx_current_cell_rate
))
556 printk("UBR PLUS set. %s, line %d returns EINVAL\n", __FUNCTION__
, __LINE__
);
563 /* check existing vpi,vci */
564 conn
= find_vpivci(vpi
, vci
);
570 /* check whether it need to enable irq */
571 if ( g_atm_priv_data
.conn_table
== 0 )
574 /* allocate connection */
575 for ( conn
= 0; conn
< MAX_PVC_NUMBER
; conn
++ ) {
576 if ( test_and_set_bit(conn
, &g_atm_priv_data
.conn_table
) == 0 ) {
577 g_atm_priv_data
.conn
[conn
].vcc
= vcc
;
581 if ( conn
== MAX_PVC_NUMBER
)
583 printk("max_pvc_number reached\n");
588 /* reserve bandwidth */
589 switch ( vcc
->qos
.txtp
.traffic_class
) {
592 port
->tx_current_cell_rate
+= vcc
->qos
.txtp
.max_pcr
;
595 port
->tx_current_cell_rate
+= vcc
->qos
.txtp
.scr
;
598 port
->tx_current_cell_rate
+= vcc
->qos
.txtp
.min_pcr
;
603 set_qsb(vcc
, &vcc
->qos
, conn
);
605 /* update atm_vcc structure */
606 vcc
->itf
= (int)vcc
->dev
->dev_data
;
609 set_bit(ATM_VF_READY
, &vcc
->flags
);
613 ifx_atm_alloc_tx
= atm_alloc_tx
;
615 *MBOX_IGU1_ISRC
= (1 << RX_DMA_CH_AAL
) | (1 << RX_DMA_CH_OAM
);
616 *MBOX_IGU1_IER
= (1 << RX_DMA_CH_AAL
) | (1 << RX_DMA_CH_OAM
);
618 enable_irq(PPE_MAILBOX_IGU1_INT
);
622 WTX_QUEUE_CONFIG(conn
+ FIRST_QSB_QID
)->sbid
= (int)vcc
->dev
->dev_data
;
625 set_htu_entry(vpi
, vci
, conn
, vcc
->qos
.aal
== ATM_AAL5
? 1 : 0, 0);
627 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
628 // ReTX: occupy second QID
629 local_irq_save(sys_flag
);
630 if ( g_retx_htu
&& vcc
->qos
.aal
== ATM_AAL5
)
632 int retx_conn
= (conn
+ 8) % 16; // ReTX queue
634 if ( retx_conn
< MAX_PVC_NUMBER
&& test_and_set_bit(retx_conn
, &g_atm_priv_data
.conn_table
) == 0 ) {
635 g_atm_priv_data
.conn
[retx_conn
].vcc
= vcc
;
636 set_htu_entry(vpi
, vci
, retx_conn
, vcc
->qos
.aal
== ATM_AAL5
? 1 : 0, 1);
639 local_irq_restore(sys_flag
);
648 static void ppe_close(struct atm_vcc
*vcc
)
652 struct connection
*connection
;
653 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
660 /* get connection id */
661 conn
= find_vcc(vcc
);
663 err("can't find vcc");
666 connection
= &g_atm_priv_data
.conn
[conn
];
667 port
= &g_atm_priv_data
.port
[connection
->port
];
670 clear_htu_entry(conn
);
672 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
673 // ReTX: release second QID
674 local_irq_save(sys_flag
);
675 if ( g_retx_htu
&& vcc
->qos
.aal
== ATM_AAL5
)
677 int retx_conn
= (conn
+ 8) % 16; // ReTX queue
679 if ( retx_conn
< MAX_PVC_NUMBER
&& g_atm_priv_data
.conn
[retx_conn
].vcc
== vcc
) {
680 clear_htu_entry(retx_conn
);
681 g_atm_priv_data
.conn
[retx_conn
].vcc
= NULL
;
682 g_atm_priv_data
.conn
[retx_conn
].aal5_vcc_crc_err
= 0;
683 g_atm_priv_data
.conn
[retx_conn
].aal5_vcc_oversize_sdu
= 0;
684 clear_bit(retx_conn
, &g_atm_priv_data
.conn_table
);
687 local_irq_restore(sys_flag
);
690 /* release connection */
691 connection
->vcc
= NULL
;
692 connection
->aal5_vcc_crc_err
= 0;
693 connection
->aal5_vcc_oversize_sdu
= 0;
694 clear_bit(conn
, &g_atm_priv_data
.conn_table
);
697 if ( g_atm_priv_data
.conn_table
== 0 ) {
698 disable_irq(PPE_MAILBOX_IGU1_INT
);
699 ifx_atm_alloc_tx
= NULL
;
702 /* release bandwidth */
703 switch ( vcc
->qos
.txtp
.traffic_class
)
707 port
->tx_current_cell_rate
-= vcc
->qos
.txtp
.max_pcr
;
710 port
->tx_current_cell_rate
-= vcc
->qos
.txtp
.scr
;
713 port
->tx_current_cell_rate
-= vcc
->qos
.txtp
.min_pcr
;
721 static int ppe_send(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
726 struct tx_descriptor reg_desc
= {0};
728 if ( vcc
== NULL
|| skb
== NULL
)
733 atm_free_tx_skb_vcc(skb
, vcc
);
735 conn
= find_vcc(vcc
);
742 err("not in showtime");
747 if ( vcc
->qos
.aal
== ATM_AAL5
) {
750 struct tx_inband_header
*header
;
753 byteoff
= (unsigned int)skb
->data
& (DATA_BUFFER_ALIGNMENT
- 1);
755 if ( skb_headroom(skb
) < byteoff
+ TX_INBAND_HEADER_LENGTH
) {
756 struct sk_buff
*new_skb
;
758 new_skb
= alloc_skb_tx(datalen
);
759 if ( new_skb
== NULL
) {
760 err("ALLOC_SKB_TX_FAIL");
764 skb_put(new_skb
, datalen
);
765 memcpy(new_skb
->data
, skb
->data
, datalen
);
766 dev_kfree_skb_any(skb
);
768 byteoff
= (unsigned int)skb
->data
& (DATA_BUFFER_ALIGNMENT
- 1);
771 skb_push(skb
, byteoff
+ TX_INBAND_HEADER_LENGTH
);
773 header
= (struct tx_inband_header
*)skb
->data
;
775 /* setup inband trailer */
778 header
->pad
= aal5_fill_pattern
;
781 /* setup cell header */
782 header
->clp
= (vcc
->atm_options
& ATM_ATMOPT_CLP
) ? 1 : 0;
783 header
->pti
= ATM_PTI_US0
;
784 header
->vci
= vcc
->vci
;
785 header
->vpi
= vcc
->vpi
;
788 /* setup descriptor */
789 reg_desc
.dataptr
= (unsigned int)skb
->data
>> 2;
790 reg_desc
.datalen
= datalen
;
791 reg_desc
.byteoff
= byteoff
;
795 /* if data pointer is not aligned, allocate new sk_buff */
796 if ( ((unsigned int)skb
->data
& (DATA_BUFFER_ALIGNMENT
- 1)) != 0 ) {
797 struct sk_buff
*new_skb
;
799 err("skb->data not aligned");
801 new_skb
= alloc_skb_tx(skb
->len
);
802 if ( new_skb
== NULL
) {
803 err("ALLOC_SKB_TX_FAIL");
807 skb_put(new_skb
, skb
->len
);
808 memcpy(new_skb
->data
, skb
->data
, skb
->len
);
809 dev_kfree_skb_any(skb
);
813 reg_desc
.dataptr
= (unsigned int)skb
->data
>> 2;
814 reg_desc
.datalen
= skb
->len
;
815 reg_desc
.byteoff
= 0;
821 reg_desc
.sop
= reg_desc
.eop
= 1;
823 desc_base
= get_tx_desc(conn
);
824 if ( desc_base
< 0 ) {
825 err("ALLOC_TX_CONNECTION_FAIL");
831 atomic_inc(&vcc
->stats
->tx
);
832 if ( vcc
->qos
.aal
== ATM_AAL5
)
833 g_atm_priv_data
.wtx_pdu
++;
835 /* update descriptor send pointer */
836 if ( g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
] != NULL
)
837 dev_kfree_skb_any(g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
]);
838 g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
] = skb
;
840 /* write discriptor to memory and write back cache */
841 #ifdef CONFIG_DEBUG_SLAB
842 /* be sure that "redzone 1" is written back to memory */
843 dma_cache_wback((unsigned long)skb
->head
, 32);
845 dma_cache_wback((unsigned long)skb_shinfo(skb
), sizeof(struct skb_shared_info
));
846 dma_cache_wback((unsigned long)skb
->data
, skb
->len
);
847 g_atm_priv_data
.conn
[conn
].tx_desc
[desc_base
] = reg_desc
;
849 dump_skb(skb
, DUMP_SKB_LEN
, (char *)__func__
, 0, conn
, 1);
851 mailbox_signal(conn
, 1);
858 err("FIND_VCC_FAIL");
859 g_atm_priv_data
.wtx_err_pdu
++;
860 dev_kfree_skb_any(skb
);
864 if ( vcc
->qos
.aal
== ATM_AAL5
)
865 g_atm_priv_data
.wtx_drop_pdu
++;
867 atomic_inc(&vcc
->stats
->tx_err
);
868 dev_kfree_skb_any(skb
);
872 static int ppe_send_oam(struct atm_vcc
*vcc
, void *cell
, int flags
)
875 struct uni_cell_header
*uni_cell_header
= (struct uni_cell_header
*)cell
;
878 struct tx_descriptor reg_desc
= {0};
880 if ( ((uni_cell_header
->pti
== ATM_PTI_SEGF5
|| uni_cell_header
->pti
== ATM_PTI_E2EF5
)
881 && find_vpivci(uni_cell_header
->vpi
, uni_cell_header
->vci
) < 0)
882 || ((uni_cell_header
->vci
== 0x03 || uni_cell_header
->vci
== 0x04)
883 && find_vpi(uni_cell_header
->vpi
) < 0) )
887 err("not in showtime");
891 conn
= find_vcc(vcc
);
893 err("FIND_VCC_FAIL");
897 skb
= alloc_skb_tx(CELL_SIZE
);
899 err("ALLOC_SKB_TX_FAIL");
902 memcpy(skb
->data
, cell
, CELL_SIZE
);
904 reg_desc
.dataptr
= (unsigned int)skb
->data
>> 2;
905 reg_desc
.datalen
= CELL_SIZE
;
906 reg_desc
.byteoff
= 0;
911 reg_desc
.sop
= reg_desc
.eop
= 1;
913 desc_base
= get_tx_desc(conn
);
914 if ( desc_base
< 0 ) {
915 dev_kfree_skb_any(skb
);
916 err("ALLOC_TX_CONNECTION_FAIL");
921 atomic_inc(&vcc
->stats
->tx
);
923 /* update descriptor send pointer */
924 if ( g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
] != NULL
)
925 dev_kfree_skb_any(g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
]);
926 g_atm_priv_data
.conn
[conn
].tx_skb
[desc_base
] = skb
;
928 /* write discriptor to memory and write back cache */
929 g_atm_priv_data
.conn
[conn
].tx_desc
[desc_base
] = reg_desc
;
930 dma_cache_wback((unsigned long)skb
->data
, CELL_SIZE
);
932 dump_skb(skb
, DUMP_SKB_LEN
, (char *)__func__
, 0, conn
, 1);
934 if ( vcc
->qos
.aal
== ATM_AAL5
&& (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_MAC_SWAP
) ) {
935 skb_swap(skb
, reg_desc
.byteoff
);
938 mailbox_signal(conn
, 1);
945 static int ppe_change_qos(struct atm_vcc
*vcc
, struct atm_qos
*qos
, int flags
)
949 if ( vcc
== NULL
|| qos
== NULL
)
952 conn
= find_vcc(vcc
);
956 set_qsb(vcc
, qos
, conn
);
961 static INLINE
void adsl_led_flash(void)
964 #if defined(ENABLE_LED_FRAMEWORK) && ENABLE_LED_FRAMEWORK
965 if ( g_data_led_trigger
!= NULL
)
966 ifx_led_trigger_activate(g_data_led_trigger
);
968 if (!IS_ERR(&ifx_mei_atm_led_blink
) && &ifx_mei_atm_led_blink
)
969 ifx_mei_atm_led_blink();
976 * Add a 32-bit value to 64-bit value, and put result in a 64-bit variable.
978 * opt1 --- ppe_u64_t, first operand, a 64-bit unsigned integer value
979 * opt2 --- unsigned int, second operand, a 32-bit unsigned integer value
980 * ret --- ppe_u64_t, pointer to a variable to hold result
984 static INLINE
void u64_add_u32(ppe_u64_t opt1
, unsigned int opt2
, ppe_u64_t
*ret
)
986 ret
->l
= opt1
.l
+ opt2
;
987 if ( ret
->l
< opt1
.l
|| ret
->l
< opt2
)
991 static INLINE
struct sk_buff
* alloc_skb_rx(void)
995 skb
= dev_alloc_skb(RX_DMA_CH_AAL_BUF_SIZE
+ DATA_BUFFER_ALIGNMENT
);
997 /* must be burst length alignment */
998 if ( ((unsigned int)skb
->data
& (DATA_BUFFER_ALIGNMENT
- 1)) != 0 )
999 skb_reserve(skb
, ~((unsigned int)skb
->data
+ (DATA_BUFFER_ALIGNMENT
- 1)) & (DATA_BUFFER_ALIGNMENT
- 1));
1000 /* pub skb in reserved area "skb->data - 4" */
1001 *((struct sk_buff
**)skb
->data
- 1) = skb
;
1002 /* write back and invalidate cache */
1003 dma_cache_wback_inv((unsigned long)skb
->data
- sizeof(skb
), sizeof(skb
));
1004 /* invalidate cache */
1005 dma_cache_inv((unsigned long)skb
->data
, (unsigned int)skb
->end
- (unsigned int)skb
->data
);
1011 static INLINE
struct sk_buff
* alloc_skb_tx(unsigned int size
)
1013 struct sk_buff
*skb
;
1015 /* allocate memory including header and padding */
1016 size
+= TX_INBAND_HEADER_LENGTH
+ MAX_TX_PACKET_ALIGN_BYTES
+ MAX_TX_PACKET_PADDING_BYTES
;
1017 size
&= ~(DATA_BUFFER_ALIGNMENT
- 1);
1018 skb
= dev_alloc_skb(size
+ DATA_BUFFER_ALIGNMENT
);
1019 /* must be burst length alignment */
1021 skb_reserve(skb
, (~((unsigned int)skb
->data
+ (DATA_BUFFER_ALIGNMENT
- 1)) & (DATA_BUFFER_ALIGNMENT
- 1)) + TX_INBAND_HEADER_LENGTH
);
1025 struct sk_buff
* atm_alloc_tx(struct atm_vcc
*vcc
, unsigned int size
)
1028 struct sk_buff
*skb
;
1030 /* oversize packet */
1031 if ( size
> aal5s_max_packet_size
) {
1032 err("atm_alloc_tx: oversize packet");
1035 /* send buffer overflow */
1036 if ( atomic_read(&sk_atm(vcc
)->sk_wmem_alloc
) && !atm_may_send(vcc
, size
) ) {
1037 err("atm_alloc_tx: send buffer overflow");
1040 conn
= find_vcc(vcc
);
1042 err("atm_alloc_tx: unknown VCC");
1046 skb
= dev_alloc_skb(size
);
1047 if ( skb
== NULL
) {
1048 err("atm_alloc_tx: sk buffer is used up");
1052 atomic_add(skb
->truesize
, &sk_atm(vcc
)->sk_wmem_alloc
);
1057 static INLINE
void atm_free_tx_skb_vcc(struct sk_buff
*skb
, struct atm_vcc
*vcc
)
1059 if ( vcc
->pop
!= NULL
)
1062 dev_kfree_skb_any(skb
);
1065 static INLINE
struct sk_buff
*get_skb_rx_pointer(unsigned int dataptr
)
1067 unsigned int skb_dataptr
;
1068 struct sk_buff
*skb
;
1070 skb_dataptr
= ((dataptr
- 1) << 2) | KSEG1
;
1071 skb
= *(struct sk_buff
**)skb_dataptr
;
1073 ASSERT((unsigned int)skb
>= KSEG0
, "invalid skb - skb = %#08x, dataptr = %#08x", (unsigned int)skb
, dataptr
);
1074 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
);
1079 static INLINE
int get_tx_desc(unsigned int conn
)
1082 struct connection
*p_conn
= &g_atm_priv_data
.conn
[conn
];
1084 if ( p_conn
->tx_desc
[p_conn
->tx_desc_pos
].own
== 0 ) {
1085 desc_base
= p_conn
->tx_desc_pos
;
1086 if ( ++(p_conn
->tx_desc_pos
) == dma_tx_descriptor_length
)
1087 p_conn
->tx_desc_pos
= 0;
1093 static INLINE
void mailbox_oam_rx_handler(void)
1095 unsigned int vlddes
= WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_OAM
)->vlddes
;
1096 struct rx_descriptor reg_desc
;
1097 struct uni_cell_header
*header
;
1099 struct atm_vcc
*vcc
;
1102 for ( i
= 0; i
< vlddes
; i
++ ) {
1104 reg_desc
= g_atm_priv_data
.oam_desc
[g_atm_priv_data
.oam_desc_pos
];
1105 } while ( reg_desc
.own
|| !reg_desc
.c
); // keep test OWN and C bit until data is ready
1107 header
= (struct uni_cell_header
*)&g_atm_priv_data
.oam_buf
[g_atm_priv_data
.oam_desc_pos
* RX_DMA_CH_OAM_BUF_SIZE
];
1109 if ( header
->pti
== ATM_PTI_SEGF5
|| header
->pti
== ATM_PTI_E2EF5
)
1110 conn
= find_vpivci(header
->vpi
, header
->vci
);
1111 else if ( header
->vci
== 0x03 || header
->vci
== 0x04 )
1112 conn
= find_vpi(header
->vpi
);
1116 if ( conn
>= 0 && g_atm_priv_data
.conn
[conn
].vcc
!= NULL
) {
1117 vcc
= g_atm_priv_data
.conn
[conn
].vcc
;
1119 if ( vcc
->push_oam
!= NULL
)
1120 vcc
->push_oam(vcc
, header
);
1122 ifx_push_oam((unsigned char *)header
);
1126 reg_desc
.byteoff
= 0;
1127 reg_desc
.datalen
= RX_DMA_CH_OAM_BUF_SIZE
;
1131 g_atm_priv_data
.oam_desc
[g_atm_priv_data
.oam_desc_pos
] = reg_desc
;
1132 if ( ++g_atm_priv_data
.oam_desc_pos
== RX_DMA_CH_OAM_DESC_LEN
)
1133 g_atm_priv_data
.oam_desc_pos
= 0;
1135 mailbox_signal(RX_DMA_CH_OAM
, 0);
1139 static INLINE
void mailbox_aal_rx_handler(void)
1141 unsigned int vlddes
= WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_AAL
)->vlddes
;
1142 struct rx_descriptor reg_desc
;
1144 struct atm_vcc
*vcc
;
1145 struct sk_buff
*skb
, *new_skb
;
1146 struct rx_inband_trailer
*trailer
;
1149 for ( i
= 0; i
< vlddes
; i
++ ) {
1151 reg_desc
= g_atm_priv_data
.aal_desc
[g_atm_priv_data
.aal_desc_pos
];
1152 } while ( reg_desc
.own
|| !reg_desc
.c
); // keep test OWN and C bit until data is ready
1156 if ( g_atm_priv_data
.conn
[conn
].vcc
!= NULL
) {
1157 vcc
= g_atm_priv_data
.conn
[conn
].vcc
;
1159 skb
= get_skb_rx_pointer(reg_desc
.dataptr
);
1161 if ( reg_desc
.err
) {
1162 if ( vcc
->qos
.aal
== ATM_AAL5
) {
1163 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
));
1164 if ( trailer
->stw_crc
)
1165 g_atm_priv_data
.conn
[conn
].aal5_vcc_crc_err
++;
1166 if ( trailer
->stw_ovz
)
1167 g_atm_priv_data
.conn
[conn
].aal5_vcc_oversize_sdu
++;
1168 g_atm_priv_data
.wrx_drop_pdu
++;
1171 atomic_inc(&vcc
->stats
->rx_drop
);
1172 atomic_inc(&vcc
->stats
->rx_err
);
1175 else if ( atm_charge(vcc
, skb
->truesize
) ) {
1176 new_skb
= alloc_skb_rx();
1177 if ( new_skb
!= NULL
) {
1178 skb_reserve(skb
, reg_desc
.byteoff
);
1179 skb_put(skb
, reg_desc
.datalen
);
1180 ATM_SKB(skb
)->vcc
= vcc
;
1182 dump_skb(skb
, DUMP_SKB_LEN
, (char *)__func__
, 0, conn
, 0);
1184 vcc
->push(vcc
, skb
);
1186 if ( vcc
->qos
.aal
== ATM_AAL5
)
1187 g_atm_priv_data
.wrx_pdu
++;
1189 atomic_inc(&vcc
->stats
->rx
);
1192 reg_desc
.dataptr
= (unsigned int)new_skb
->data
>> 2;
1195 atm_return(vcc
, skb
->truesize
);
1196 if ( vcc
->qos
.aal
== ATM_AAL5
)
1197 g_atm_priv_data
.wrx_drop_pdu
++;
1199 atomic_inc(&vcc
->stats
->rx_drop
);
1203 if ( vcc
->qos
.aal
== ATM_AAL5
)
1204 g_atm_priv_data
.wrx_drop_pdu
++;
1206 atomic_inc(&vcc
->stats
->rx_drop
);
1210 g_atm_priv_data
.wrx_drop_pdu
++;
1213 reg_desc
.byteoff
= 0;
1214 reg_desc
.datalen
= RX_DMA_CH_AAL_BUF_SIZE
;
1218 g_atm_priv_data
.aal_desc
[g_atm_priv_data
.aal_desc_pos
] = reg_desc
;
1219 if ( ++g_atm_priv_data
.aal_desc_pos
== dma_rx_descriptor_length
)
1220 g_atm_priv_data
.aal_desc_pos
= 0;
1222 mailbox_signal(RX_DMA_CH_AAL
, 0);
1226 #if defined(ENABLE_TASKLET) && ENABLE_TASKLET
1227 static void do_ppe_tasklet(unsigned long arg
)
1229 *MBOX_IGU1_ISRC
= *MBOX_IGU1_ISR
;
1230 mailbox_oam_rx_handler();
1231 mailbox_aal_rx_handler();
1232 if ( (*MBOX_IGU1_ISR
& ((1 << RX_DMA_CH_AAL
) | (1 << RX_DMA_CH_OAM
))) != 0 )
1233 tasklet_schedule(&g_dma_tasklet
);
1235 enable_irq(PPE_MAILBOX_IGU1_INT
);
1239 static irqreturn_t
mailbox_irq_handler(int irq
, void *dev_id
)
1241 if ( !*MBOX_IGU1_ISR
)
1244 #if defined(ENABLE_TASKLET) && ENABLE_TASKLET
1245 disable_irq(PPE_MAILBOX_IGU1_INT
);
1246 tasklet_schedule(&g_dma_tasklet
);
1248 *MBOX_IGU1_ISRC
= *MBOX_IGU1_ISR
;
1249 mailbox_oam_rx_handler();
1250 mailbox_aal_rx_handler();
1256 static INLINE
void mailbox_signal(unsigned int queue
, int is_tx
)
1261 while ( MBOX_IGU3_ISR_ISR(queue
+ FIRST_QSB_QID
+ 16) && count
)
1263 *MBOX_IGU3_ISRS
= MBOX_IGU3_ISRS_SET(queue
+ FIRST_QSB_QID
+ 16);
1266 while ( MBOX_IGU3_ISR_ISR(queue
) && count
)
1268 *MBOX_IGU3_ISRS
= MBOX_IGU3_ISRS_SET(queue
);
1270 ASSERT(count
!= 0, "MBOX_IGU3_ISR = 0x%08x", ltq_r32(MBOX_IGU3_ISR
));
1273 static void set_qsb(struct atm_vcc
*vcc
, struct atm_qos
*qos
, unsigned int queue
)
1275 struct clk
*clk
= clk_get(0, "fpi");
1276 unsigned int qsb_clk
= clk_get_rate(clk
);
1277 unsigned int qsb_qid
= queue
+ FIRST_QSB_QID
;
1278 union qsb_queue_parameter_table qsb_queue_parameter_table
= {{0}};
1279 union qsb_queue_vbr_parameter_table qsb_queue_vbr_parameter_table
= {{0}};
1282 #if defined(DEBUG_QOS) && DEBUG_QOS
1283 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) ) {
1284 static char *str_traffic_class
[9] = {
1295 printk(KERN_INFO
"QoS Parameters:\n");
1296 printk(KERN_INFO
"\tAAL : %d\n", qos
->aal
);
1297 printk(KERN_INFO
"\tTX Traffic Class: %s\n", str_traffic_class
[qos
->txtp
.traffic_class
]);
1298 printk(KERN_INFO
"\tTX Max PCR : %d\n", qos
->txtp
.max_pcr
);
1299 printk(KERN_INFO
"\tTX Min PCR : %d\n", qos
->txtp
.min_pcr
);
1300 printk(KERN_INFO
"\tTX PCR : %d\n", qos
->txtp
.pcr
);
1301 printk(KERN_INFO
"\tTX Max CDV : %d\n", qos
->txtp
.max_cdv
);
1302 printk(KERN_INFO
"\tTX Max SDU : %d\n", qos
->txtp
.max_sdu
);
1303 printk(KERN_INFO
"\tTX SCR : %d\n", qos
->txtp
.scr
);
1304 printk(KERN_INFO
"\tTX MBS : %d\n", qos
->txtp
.mbs
);
1305 printk(KERN_INFO
"\tTX CDV : %d\n", qos
->txtp
.cdv
);
1306 printk(KERN_INFO
"\tRX Traffic Class: %s\n", str_traffic_class
[qos
->rxtp
.traffic_class
]);
1307 printk(KERN_INFO
"\tRX Max PCR : %d\n", qos
->rxtp
.max_pcr
);
1308 printk(KERN_INFO
"\tRX Min PCR : %d\n", qos
->rxtp
.min_pcr
);
1309 printk(KERN_INFO
"\tRX PCR : %d\n", qos
->rxtp
.pcr
);
1310 printk(KERN_INFO
"\tRX Max CDV : %d\n", qos
->rxtp
.max_cdv
);
1311 printk(KERN_INFO
"\tRX Max SDU : %d\n", qos
->rxtp
.max_sdu
);
1312 printk(KERN_INFO
"\tRX SCR : %d\n", qos
->rxtp
.scr
);
1313 printk(KERN_INFO
"\tRX MBS : %d\n", qos
->rxtp
.mbs
);
1314 printk(KERN_INFO
"\tRX CDV : %d\n", qos
->rxtp
.cdv
);
1316 #endif // defined(DEBUG_QOS) && DEBUG_QOS
1319 * Peak Cell Rate (PCR) Limiter
1321 if ( qos
->txtp
.max_pcr
== 0 )
1322 qsb_queue_parameter_table
.bit
.tp
= 0; /* disable PCR limiter */
1324 /* peak cell rate would be slightly lower than requested [maximum_rate / pcr = (qsb_clock / 8) * (time_step / 4) / pcr] */
1325 tmp
= ((qsb_clk
* qsb_tstep
) >> 5) / qos
->txtp
.max_pcr
+ 1;
1326 /* check if overflow takes place */
1327 qsb_queue_parameter_table
.bit
.tp
= tmp
> QSB_TP_TS_MAX
? QSB_TP_TS_MAX
: tmp
;
1330 // A funny issue. Create two PVCs, one UBR and one UBR with max_pcr.
1331 // Send packets to these two PVCs at same time, it trigger strange behavior.
1332 // In A1, RAM from 0x80000000 to 0x0x8007FFFF was corrupted with fixed pattern 0x00000000 0x40000000.
1333 // In A4, PPE firmware keep emiting unknown cell and do not respond to driver.
1334 // To work around, create UBR always with max_pcr.
1335 // If user want to create UBR without max_pcr, we give a default one larger than line-rate.
1336 if ( qos
->txtp
.traffic_class
== ATM_UBR
&& qsb_queue_parameter_table
.bit
.tp
== 0 ) {
1337 int port
= g_atm_priv_data
.conn
[queue
].port
;
1338 unsigned int max_pcr
= g_atm_priv_data
.port
[port
].tx_max_cell_rate
+ 1000;
1340 tmp
= ((qsb_clk
* qsb_tstep
) >> 5) / max_pcr
+ 1;
1341 if ( tmp
> QSB_TP_TS_MAX
)
1342 tmp
= QSB_TP_TS_MAX
;
1345 qsb_queue_parameter_table
.bit
.tp
= tmp
;
1349 * Weighted Fair Queueing Factor (WFQF)
1351 switch ( qos
->txtp
.traffic_class
) {
1354 /* real time queue gets weighted fair queueing bypass */
1355 qsb_queue_parameter_table
.bit
.wfqf
= 0;
1359 /* WFQF calculation here is based on virtual cell rates, to reduce granularity for high rates */
1360 /* WFQF is maximum cell rate / garenteed cell rate */
1361 /* wfqf = qsb_minimum_cell_rate * QSB_WFQ_NONUBR_MAX / requested_minimum_peak_cell_rate */
1362 if ( qos
->txtp
.min_pcr
== 0 )
1363 qsb_queue_parameter_table
.bit
.wfqf
= QSB_WFQ_NONUBR_MAX
;
1366 tmp
= QSB_GCR_MIN
* QSB_WFQ_NONUBR_MAX
/ qos
->txtp
.min_pcr
;
1368 qsb_queue_parameter_table
.bit
.wfqf
= 1;
1369 else if ( tmp
> QSB_WFQ_NONUBR_MAX
)
1370 qsb_queue_parameter_table
.bit
.wfqf
= QSB_WFQ_NONUBR_MAX
;
1372 qsb_queue_parameter_table
.bit
.wfqf
= tmp
;
1377 qsb_queue_parameter_table
.bit
.wfqf
= QSB_WFQ_UBR_BYPASS
;
1381 * Sustained Cell Rate (SCR) Leaky Bucket Shaper VBR.0/VBR.1
1383 if ( qos
->txtp
.traffic_class
== ATM_VBR_RT
|| qos
->txtp
.traffic_class
== ATM_VBR_NRT
) {
1384 if ( qos
->txtp
.scr
== 0 ) {
1385 /* disable shaper */
1386 qsb_queue_vbr_parameter_table
.bit
.taus
= 0;
1387 qsb_queue_vbr_parameter_table
.bit
.ts
= 0;
1390 /* Cell Loss Priority (CLP) */
1391 if ( (vcc
->atm_options
& ATM_ATMOPT_CLP
) )
1393 qsb_queue_parameter_table
.bit
.vbr
= 1;
1396 qsb_queue_parameter_table
.bit
.vbr
= 0;
1397 /* Rate Shaper Parameter (TS) and Burst Tolerance Parameter for SCR (tauS) */
1398 tmp
= ((qsb_clk
* qsb_tstep
) >> 5) / qos
->txtp
.scr
+ 1;
1399 qsb_queue_vbr_parameter_table
.bit
.ts
= tmp
> QSB_TP_TS_MAX
? QSB_TP_TS_MAX
: tmp
;
1400 tmp
= (qos
->txtp
.mbs
- 1) * (qsb_queue_vbr_parameter_table
.bit
.ts
- qsb_queue_parameter_table
.bit
.tp
) / 64;
1402 qsb_queue_vbr_parameter_table
.bit
.taus
= 1;
1403 else if ( tmp
> QSB_TAUS_MAX
)
1404 qsb_queue_vbr_parameter_table
.bit
.taus
= QSB_TAUS_MAX
;
1406 qsb_queue_vbr_parameter_table
.bit
.taus
= tmp
;
1410 qsb_queue_vbr_parameter_table
.bit
.taus
= 0;
1411 qsb_queue_vbr_parameter_table
.bit
.ts
= 0;
1414 /* Queue Parameter Table (QPT) */
1415 *QSB_RTM
= QSB_RTM_DM_SET(QSB_QPT_SET_MASK
);
1416 *QSB_RTD
= QSB_RTD_TTV_SET(qsb_queue_parameter_table
.dword
);
1417 *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
);
1418 #if defined(DEBUG_QOS) && DEBUG_QOS
1419 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) )
1420 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
);
1422 /* Queue VBR Paramter Table (QVPT) */
1423 *QSB_RTM
= QSB_RTM_DM_SET(QSB_QVPT_SET_MASK
);
1424 *QSB_RTD
= QSB_RTD_TTV_SET(qsb_queue_vbr_parameter_table
.dword
);
1425 *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
);
1426 #if defined(DEBUG_QOS) && DEBUG_QOS
1427 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) )
1428 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
);
1431 #if defined(DEBUG_QOS) && DEBUG_QOS
1432 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) ) {
1433 printk("set_qsb\n");
1434 printk(" qsb_clk = %lu\n", (unsigned long)qsb_clk
);
1435 printk(" qsb_queue_parameter_table.bit.tp = %d\n", (int)qsb_queue_parameter_table
.bit
.tp
);
1436 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
);
1437 printk(" qsb_queue_parameter_table.bit.vbr = %d\n", (int)qsb_queue_parameter_table
.bit
.vbr
);
1438 printk(" qsb_queue_parameter_table.dword = 0x%08X\n", (int)qsb_queue_parameter_table
.dword
);
1439 printk(" qsb_queue_vbr_parameter_table.bit.ts = %d\n", (int)qsb_queue_vbr_parameter_table
.bit
.ts
);
1440 printk(" qsb_queue_vbr_parameter_table.bit.taus = %d\n", (int)qsb_queue_vbr_parameter_table
.bit
.taus
);
1441 printk(" qsb_queue_vbr_parameter_table.dword = 0x%08X\n", (int)qsb_queue_vbr_parameter_table
.dword
);
1446 static void qsb_global_set(void)
1448 struct clk
*clk
= clk_get(0, "fpi");
1449 unsigned int qsb_clk
= clk_get_rate(clk
);
1451 unsigned int tmp1
, tmp2
, tmp3
;
1453 *QSB_ICDV
= QSB_ICDV_TAU_SET(qsb_tau
);
1454 *QSB_SBL
= QSB_SBL_SBL_SET(qsb_srvm
);
1455 *QSB_CFG
= QSB_CFG_TSTEPC_SET(qsb_tstep
>> 1);
1456 #if defined(DEBUG_QOS) && DEBUG_QOS
1457 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) ) {
1458 printk("qsb_clk = %u\n", qsb_clk
);
1459 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));
1464 * set SCT and SPT per port
1466 for ( i
= 0; i
< ATM_PORT_NUMBER
; i
++ ) {
1467 if ( g_atm_priv_data
.port
[i
].tx_max_cell_rate
!= 0 ) {
1468 tmp1
= ((qsb_clk
* qsb_tstep
) >> 1) / g_atm_priv_data
.port
[i
].tx_max_cell_rate
;
1469 tmp2
= tmp1
>> 6; /* integer value of Tsb */
1470 tmp3
= (tmp1
& ((1 << 6) - 1)) + 1; /* fractional part of Tsb */
1471 /* carry over to integer part (?) */
1472 if ( tmp3
== (1 << 6) )
1480 /* 2. write value to data transfer register */
1481 /* 3. start the tranfer */
1482 /* SCT (FracRate) */
1483 *QSB_RTM
= QSB_RTM_DM_SET(QSB_SET_SCT_MASK
);
1484 *QSB_RTD
= QSB_RTD_TTV_SET(tmp3
);
1485 *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);
1486 #if defined(DEBUG_QOS) && DEBUG_QOS
1487 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) )
1488 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
);
1490 /* SPT (SBV + PN + IntRage) */
1491 *QSB_RTM
= QSB_RTM_DM_SET(QSB_SET_SPT_MASK
);
1492 *QSB_RTD
= QSB_RTD_TTV_SET(QSB_SPT_SBV_VALID
| QSB_SPT_PN_SET(i
& 0x01) | QSB_SPT_INTRATE_SET(tmp2
));
1493 *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);
1494 #if defined(DEBUG_QOS) && DEBUG_QOS
1495 if ( (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) )
1496 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
);
1502 static INLINE
void set_htu_entry(unsigned int vpi
, unsigned int vci
, unsigned int queue
, int aal5
, int is_retx
)
1504 struct htu_entry htu_entry
= { res1
: 0x00,
1505 clp
: is_retx
? 0x01 : 0x00,
1506 pid
: g_atm_priv_data
.conn
[queue
].port
& 0x01,
1512 struct htu_mask htu_mask
= { set
: 0x01,
1513 #if !defined(ENABLE_ATM_RETX) || !ENABLE_ATM_RETX
1517 clp
: g_retx_htu
? 0x00 : 0x01,
1518 pid_mask
: RETX_MODE_CFG
->retx_en
? 0x03 : 0x02,
1521 #if !defined(ENABLE_ATM_RETX) || !ENABLE_ATM_RETX
1524 vci_mask
: RETX_MODE_CFG
->retx_en
? 0xFF00 : 0x0000,
1526 pti_mask
: 0x03, // 0xx, user data
1529 struct htu_result htu_result
= {res1
: 0x00,
1532 type
: aal5
? 0x00 : 0x01,
1537 *HTU_RESULT(queue
+ OAM_HTU_ENTRY_NUMBER
) = htu_result
;
1538 *HTU_MASK(queue
+ OAM_HTU_ENTRY_NUMBER
) = htu_mask
;
1539 *HTU_ENTRY(queue
+ OAM_HTU_ENTRY_NUMBER
) = htu_entry
;
1542 static INLINE
void clear_htu_entry(unsigned int queue
)
1544 HTU_ENTRY(queue
+ OAM_HTU_ENTRY_NUMBER
)->vld
= 0;
1547 static void validate_oam_htu_entry(void)
1549 HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY
)->vld
= 1;
1550 HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY
)->vld
= 1;
1551 HTU_ENTRY(OAM_F5_HTU_ENTRY
)->vld
= 1;
1552 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
1553 HTU_ENTRY(OAM_ARQ_HTU_ENTRY
)->vld
= 1;
1557 static void invalidate_oam_htu_entry(void)
1559 HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY
)->vld
= 0;
1560 HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY
)->vld
= 0;
1561 HTU_ENTRY(OAM_F5_HTU_ENTRY
)->vld
= 0;
1562 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
1563 HTU_ENTRY(OAM_ARQ_HTU_ENTRY
)->vld
= 0;
1567 static INLINE
int find_vpi(unsigned int vpi
)
1572 for ( i
= 0, bit
= 1; i
< MAX_PVC_NUMBER
; i
++, bit
<<= 1 ) {
1573 if ( (g_atm_priv_data
.conn_table
& bit
) != 0
1574 && g_atm_priv_data
.conn
[i
].vcc
!= NULL
1575 && vpi
== g_atm_priv_data
.conn
[i
].vcc
->vpi
)
1582 static INLINE
int find_vpivci(unsigned int vpi
, unsigned int vci
)
1587 for ( i
= 0, bit
= 1; i
< MAX_PVC_NUMBER
; i
++, bit
<<= 1 ) {
1588 if ( (g_atm_priv_data
.conn_table
& bit
) != 0
1589 && g_atm_priv_data
.conn
[i
].vcc
!= NULL
1590 && vpi
== g_atm_priv_data
.conn
[i
].vcc
->vpi
1591 && vci
== g_atm_priv_data
.conn
[i
].vcc
->vci
)
1598 static INLINE
int find_vcc(struct atm_vcc
*vcc
)
1603 for ( i
= 0, bit
= 1; i
< MAX_PVC_NUMBER
; i
++, bit
<<= 1 ) {
1604 if ( (g_atm_priv_data
.conn_table
& bit
) != 0
1605 && g_atm_priv_data
.conn
[i
].vcc
== vcc
)
1612 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
1614 static void retx_polling_func(unsigned long arg
)
1617 volatile struct dsl_param
*p_dsl_param
;
1622 local_irq_save(sys_flag
);
1623 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
) ) {
1624 local_irq_restore(sys_flag
);
1625 g_retx_playout_buffer
= __get_free_pages(GFP_KERNEL
, RETX_PLAYOUT_BUFFER_ORDER
);
1626 if ( g_retx_playout_buffer
== 0 )
1627 panic("no memory for g_retx_playout_buffer\n");
1628 memset((void *)g_retx_playout_buffer
, 0, RETX_PLAYOUT_BUFFER_SIZE
);
1629 dma_cache_inv(g_retx_playout_buffer
, RETX_PLAYOUT_BUFFER_SIZE
);
1632 local_irq_restore(sys_flag
);
1635 local_irq_save(sys_flag
);
1636 if ( g_xdata_addr
!= NULL
) {
1637 p_dsl_param
= (volatile struct dsl_param
*)g_xdata_addr
;
1638 g_retx_polling_cnt
+= RETX_POLLING_INTERVAL
;
1640 if ( p_dsl_param
->update_flag
) {
1641 do_gettimeofday(&g_retx_polling_start
);
1643 g_dsl_param
= *p_dsl_param
;
1645 // we always enable retx (just for test purpose)
1646 //g_dsl_param.RetxEnable = 1;
1647 //RETX_TSYNC_CFG->fw_alpha = 0;
1649 if ( g_dsl_param
.RetxEnable
|| g_dsl_param
.ServiceSpecificReTx
) {
1651 // MIB counter updated for each polling
1652 p_dsl_param
->RxDtuCorruptedCNT
= *RxDTUCorruptedCNT
;
1653 p_dsl_param
->RxRetxDtuUnCorrectedCNT
= *RxRetxDTUUncorrectedCNT
;
1654 p_dsl_param
->RxLastEFB
= *RxLastEFBCNT
;
1655 p_dsl_param
->RxDtuCorrectedCNT
= *RxDTUCorrectedCNT
;
1657 // for RETX paramters, we check only once for every second
1658 if ( g_retx_polling_cnt
< HZ
)
1659 goto _clear_update_flag
;
1661 g_retx_polling_cnt
-= HZ
;
1663 if ( g_dsl_param
.ServiceSpecificReTx
&& g_dsl_param
.ReTxPVC
== 0 )
1668 // default fw_alpha equals to default hardware alpha
1669 RETX_TSYNC_CFG
->fw_alpha
= 0;
1671 RETX_TD_CFG
->td_max
= g_dsl_param
.MaxDelayrt
;
1672 RETX_TD_CFG
->td_min
= g_dsl_param
.MinDelayrt
;
1674 *RETX_PLAYOUT_BUFFER_BASE
= ((((unsigned int)g_retx_playout_buffer
| KSEG1
) + 15) & 0xFFFFFFF0) >> 2;
1676 if ( g_dsl_param
.ServiceSpecificReTx
) {
1677 *RETX_SERVICE_HEADER_CFG
= g_dsl_param
.ReTxPVC
<< 4;
1678 if ( g_dsl_param
.ReTxPVC
== 0 )
1679 *RETX_MASK_HEADER_CFG
= 1;
1681 *RETX_MASK_HEADER_CFG
= 0;
1684 *RETX_SERVICE_HEADER_CFG
= 0;
1685 *RETX_MASK_HEADER_CFG
= 0;
1695 RETX_TSYNC_CFG
->fw_alpha
= 7;
1697 *RETX_SERVICE_HEADER_CFG
= 0;
1698 *RETX_MASK_HEADER_CFG
= 0;
1704 if ( retx_en
!= RETX_MODE_CFG
->retx_en
) {
1705 unsigned int pid_mask
, vci_mask
;
1716 max_htu
= *CFG_WRX_HTUTS
;
1717 for ( i
= OAM_HTU_ENTRY_NUMBER
; i
< max_htu
; i
++ )
1718 if ( HTU_ENTRY(i
)->vld
) {
1719 HTU_MASK(i
)->pid_mask
= pid_mask
;
1720 HTU_MASK(i
)->vci_mask
= vci_mask
;
1724 if ( new_retx_htu
!= g_retx_htu
) {
1725 int conn
, retx_conn
;
1727 g_retx_htu
= new_retx_htu
;
1730 max_htu
= *CFG_WRX_HTUTS
;
1731 for ( i
= OAM_HTU_ENTRY_NUMBER
; i
< max_htu
; i
++ )
1732 if ( HTU_ENTRY(i
)->vld
)
1733 HTU_MASK(i
)->clp
= 0;
1735 for ( conn
= 0; conn
< MAX_PVC_NUMBER
; conn
++ )
1736 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
) {
1737 retx_conn
= (conn
+ 8) % 16; // ReTX queue
1739 if ( retx_conn
< MAX_PVC_NUMBER
&& test_and_set_bit(retx_conn
, &g_atm_priv_data
.conn_table
) == 0 ) {
1740 g_atm_priv_data
.conn
[retx_conn
].vcc
= g_atm_priv_data
.conn
[conn
].vcc
;
1741 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);
1744 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
);
1750 for ( retx_conn
= 0; retx_conn
< MAX_PVC_NUMBER
; retx_conn
++ )
1751 if ( g_atm_priv_data
.conn
[retx_conn
].vcc
&& HTU_ENTRY(retx_conn
+ OAM_HTU_ENTRY_NUMBER
)->clp
) {
1752 clear_htu_entry(retx_conn
);
1753 g_atm_priv_data
.conn
[retx_conn
].vcc
= NULL
;
1754 g_atm_priv_data
.conn
[retx_conn
].aal5_vcc_crc_err
= 0;
1755 g_atm_priv_data
.conn
[retx_conn
].aal5_vcc_oversize_sdu
= 0;
1756 clear_bit(retx_conn
, &g_atm_priv_data
.conn_table
);
1759 max_htu
= *CFG_WRX_HTUTS
;
1760 for ( i
= OAM_HTU_ENTRY_NUMBER
; i
< max_htu
; i
++ )
1761 if ( HTU_ENTRY(i
)->vld
)
1762 HTU_MASK(i
)->clp
= 1;
1766 RETX_MODE_CFG
->retx_en
= retx_en
;
1769 p_dsl_param
->update_flag
= 0;
1771 do_gettimeofday(&g_retx_polling_end
);
1774 g_retx_polling_timer
.expires
= jiffies
+ RETX_POLLING_INTERVAL
;
1775 add_timer(&g_retx_polling_timer
);
1777 local_irq_restore(sys_flag
);
1780 static int init_atm_tc_retrans_param(void)
1783 struct DTU_stat_info reset_val
;
1785 RETX_MODE_CFG
->invld_range
= 128;
1786 RETX_MODE_CFG
->buff_size
= RETX_PLAYOUT_FW_BUFF_SIZE
> 4096/32 ? 4096/32 : RETX_PLAYOUT_FW_BUFF_SIZE
;
1787 RETX_MODE_CFG
->retx_en
= 1;
1789 // default fw_alpha equals to default hardware alpha
1790 RETX_TSYNC_CFG
->fw_alpha
= 7;
1791 RETX_TSYNC_CFG
->sync_inp
= 0;
1793 RETX_TD_CFG
->td_max
= 0;
1794 RETX_TD_CFG
->td_min
= 0;
1796 // *RETX_PLAYOUT_BUFFER_BASE = KSEG1ADDR(g_retx_playout_buffer); // need " >> 2 " ?
1797 *RETX_PLAYOUT_BUFFER_BASE
= ((((unsigned int)g_retx_playout_buffer
| KSEG1
) + 15) & 0xFFFFFFF0) >> 2;
1799 *RETX_SERVICE_HEADER_CFG
= 0;
1800 *RETX_MASK_HEADER_CFG
= 0;
1803 RETX_MIB_TIMER_CFG
->tick_cycle
= 4800;
1804 RETX_MIB_TIMER_CFG
->ticks_per_sec
= 50000;
1806 *LAST_DTU_SID_IN
= 255;
1808 // init DTU_STAT_INFO
1810 memset(&reset_val
, 0, sizeof(reset_val
));
1811 reset_val
.dtu_rd_ptr
= reset_val
.dtu_wr_ptr
= 0xffff;
1813 for(i
= 0 ; i
< 256; i
++) {
1814 DTU_STAT_INFO
[i
] = reset_val
;
1819 static void clear_atm_tc_retrans_param(void)
1821 if ( g_retx_playout_buffer
) {
1822 free_pages(g_retx_playout_buffer
, RETX_PLAYOUT_BUFFER_ORDER
);
1823 g_retx_playout_buffer
= 0;
1829 #if defined(DEBUG_DUMP_SKB) && DEBUG_DUMP_SKB
1830 static void dump_skb(struct sk_buff
*skb
, unsigned int len
, char *title
, int port
, int ch
, int is_tx
)
1834 if ( !(ifx_atm_dbg_enable
& (is_tx
? DBG_ENABLE_MASK_DUMP_SKB_TX
: DBG_ENABLE_MASK_DUMP_SKB_RX
)) )
1837 if ( skb
->len
< len
)
1840 if ( len
> RX_DMA_CH_AAL_BUF_SIZE
) {
1841 printk("too big data length: skb = %08x, skb->data = %08x, skb->len = %d\n", (unsigned int)skb
, (unsigned int)skb
->data
, skb
->len
);
1846 printk("%s (port %d, ch %d)\n", title
, port
, ch
);
1848 printk("%s\n", title
);
1849 printk(" skb->data = %08X, skb->tail = %08X, skb->len = %d\n", (unsigned int)skb
->data
, (unsigned int)skb
->tail
, (int)skb
->len
);
1850 for ( i
= 1; i
<= len
; i
++ ) {
1852 printk(" %4d:", i
- 1);
1853 printk(" %02X", (int)(*((char*)skb
->data
+ i
- 1) & 0xFF));
1857 if ( (i
- 1) % 16 != 0 )
1862 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
1863 static void skb_swap(struct sk_buff
*skb
, unsigned int byteoff
)
1865 unsigned int mac_offset
= ~0;
1866 unsigned int ip_offset
= ~0;
1867 unsigned char tmp
[8];
1868 unsigned char *p
= NULL
;
1870 skb_pull(skb
, byteoff
+ TX_INBAND_HEADER_LENGTH
);
1872 if ( skb
->data
[0] == 0xAA && skb
->data
[1] == 0xAA && skb
->data
[2] == 0x03 ) {
1874 if ( skb
->data
[3] == 0x00 && skb
->data
[4] == 0x80 && skb
->data
[5] == 0xC2 ) {
1876 if ( skb
->data
[22] == 0x08 && skb
->data
[23] == 0x00 ) {
1881 else if ( skb
->data
[31] == 0x21 ) {
1889 if ( skb
->data
[6] == 0x08 && skb
->data
[7] == 0x00 ) {
1895 else if ( skb
->data
[0] == 0xFE && skb
->data
[1] == 0xFE && skb
->data
[2] == 0x03 ) {
1897 if ( skb
->data
[4] == 0x00 && skb
->data
[5] == 0x21 ) {
1904 if ( skb
->data
[0] == 0x00 && skb
->data
[1] == 0x21 ) {
1908 else if ( skb
->data
[0] == 0x00 && skb
->data
[1] == 0x00 ) {
1910 if ( skb
->data
[14] == 0x08 && skb
->data
[15] ==0x00 ) {
1915 else if ( skb
->data
[23] == 0x21 ) {
1927 if ( mac_offset
!= ~0 && !(skb
->data
[mac_offset
] & 0x01) ) {
1928 p
= skb
->data
+ mac_offset
;
1931 memcpy(p
, p
+ 6, 6);
1932 memcpy(p
+ 6, tmp
, 6);
1936 if ( ip_offset
!= ~0 ) {
1937 p
= skb
->data
+ ip_offset
+ 12;
1940 memcpy(p
, p
+ 4, 4);
1941 memcpy(p
+ 4, tmp
, 4);
1946 dma_cache_wback((unsigned long)skb
->data
, (unsigned long)p
- (unsigned long)skb
->data
);
1949 skb_push(skb
, byteoff
+ TX_INBAND_HEADER_LENGTH
);
1953 static INLINE
void proc_file_create(void)
1955 struct proc_dir_entry
*res
;
1957 g_atm_dir
= proc_mkdir("driver/ifx_atm", NULL
);
1959 create_proc_read_entry("version",
1965 res
= create_proc_entry("mib",
1968 if ( res
!= NULL
) {
1969 res
->read_proc
= proc_read_mib
;
1970 res
->write_proc
= proc_write_mib
;
1973 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
1974 res
= create_proc_entry("retx_mib",
1977 if ( res
!= NULL
) {
1978 res
->read_proc
= proc_read_retx_mib
;
1979 res
->write_proc
= proc_write_retx_mib
;
1983 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
1984 res
= create_proc_entry("dbg",
1987 if ( res
!= NULL
) {
1988 res
->read_proc
= proc_read_dbg
;
1989 res
->write_proc
= proc_write_dbg
;
1992 res
= create_proc_entry("mem",
1996 res
->write_proc
= proc_write_mem
;
1998 #if defined(CONFIG_AR9) || defined(CONFIG_VR9) || defined(CONFIG_DANUBE) || defined(CONFIG_AMAZON_SE)
1999 res
= create_proc_entry("pp32",
2002 if ( res
!= NULL
) {
2003 res
->read_proc
= proc_read_pp32
;
2004 res
->write_proc
= proc_write_pp32
;
2009 #if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
2010 create_proc_read_entry("htu",
2016 create_proc_read_entry("txq",
2022 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
2023 create_proc_read_entry("retx_fw",
2029 res
= create_proc_entry("retx_stats",
2032 if ( res
!= NULL
) {
2033 res
->read_proc
= proc_read_retx_stats
;
2034 res
->write_proc
= proc_write_retx_stats
;
2037 res
= create_proc_entry("retx_cfg",
2040 if ( res
!= NULL
) {
2041 res
->read_proc
= proc_read_retx_cfg
;
2042 res
->write_proc
= proc_write_retx_cfg
;
2045 create_proc_read_entry("retx_dsl_param",
2048 proc_read_retx_dsl_param
,
2054 static INLINE
void proc_file_delete(void)
2056 #if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
2057 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
2058 remove_proc_entry("retx_dsl_param", g_atm_dir
);
2060 remove_proc_entry("retx_cfg", g_atm_dir
);
2062 remove_proc_entry("retx_stats", g_atm_dir
);
2064 remove_proc_entry("retx_fw", g_atm_dir
);
2067 remove_proc_entry("txq", g_atm_dir
);
2069 remove_proc_entry("htu", g_atm_dir
);
2072 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
2073 #if defined(CONFIG_AR9) || defined(CONFIG_VR9) || defined(CONFIG_DANUBE) || defined(CONFIG_AMAZON_SE)
2074 remove_proc_entry("pp32", g_atm_dir
);
2077 remove_proc_entry("mem", g_atm_dir
);
2079 remove_proc_entry("dbg", g_atm_dir
);
2082 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
2083 remove_proc_entry("retx_mib", g_atm_dir
);
2086 remove_proc_entry("mib", g_atm_dir
);
2088 remove_proc_entry("version", g_atm_dir
);
2090 remove_proc_entry("driver/ifx_atm", NULL
);
2093 static int proc_read_version(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
2097 len
+= ifx_atm_version(buf
+ len
);
2099 if ( offset
>= len
) {
2104 *start
= buf
+ offset
;
2105 if ( (len
-= offset
) > count
)
2111 static int proc_read_mib(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2115 len
+= sprintf(page
+ off
+ len
, "Firmware\n");
2116 len
+= sprintf(page
+ off
+ len
, " wrx_drophtu_cell = %u\n", WAN_MIB_TABLE
->wrx_drophtu_cell
);
2117 len
+= sprintf(page
+ off
+ len
, " wrx_dropdes_pdu = %u\n", WAN_MIB_TABLE
->wrx_dropdes_pdu
);
2118 len
+= sprintf(page
+ off
+ len
, " wrx_correct_pdu = %u\n", WAN_MIB_TABLE
->wrx_correct_pdu
);
2119 len
+= sprintf(page
+ off
+ len
, " wrx_err_pdu = %u\n", WAN_MIB_TABLE
->wrx_err_pdu
);
2120 len
+= sprintf(page
+ off
+ len
, " wrx_dropdes_cell = %u\n", WAN_MIB_TABLE
->wrx_dropdes_cell
);
2121 len
+= sprintf(page
+ off
+ len
, " wrx_correct_cell = %u\n", WAN_MIB_TABLE
->wrx_correct_cell
);
2122 len
+= sprintf(page
+ off
+ len
, " wrx_err_cell = %u\n", WAN_MIB_TABLE
->wrx_err_cell
);
2123 len
+= sprintf(page
+ off
+ len
, " wrx_total_byte = %u\n", WAN_MIB_TABLE
->wrx_total_byte
);
2124 len
+= sprintf(page
+ off
+ len
, " wtx_total_pdu = %u\n", WAN_MIB_TABLE
->wtx_total_pdu
);
2125 len
+= sprintf(page
+ off
+ len
, " wtx_total_cell = %u\n", WAN_MIB_TABLE
->wtx_total_cell
);
2126 len
+= sprintf(page
+ off
+ len
, " wtx_total_byte = %u\n", WAN_MIB_TABLE
->wtx_total_byte
);
2127 len
+= sprintf(page
+ off
+ len
, "Driver\n");
2128 len
+= sprintf(page
+ off
+ len
, " wrx_pdu = %u\n", g_atm_priv_data
.wrx_pdu
);
2129 len
+= sprintf(page
+ off
+ len
, " wrx_drop_pdu = %u\n", g_atm_priv_data
.wrx_drop_pdu
);
2130 len
+= sprintf(page
+ off
+ len
, " wtx_pdu = %u\n", g_atm_priv_data
.wtx_pdu
);
2131 len
+= sprintf(page
+ off
+ len
, " wtx_err_pdu = %u\n", g_atm_priv_data
.wtx_err_pdu
);
2132 len
+= sprintf(page
+ off
+ len
, " wtx_drop_pdu = %u\n", g_atm_priv_data
.wtx_drop_pdu
);
2139 static int proc_write_mib(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2145 len
= count
< sizeof(str
) ? count
: sizeof(str
) - 1;
2146 rlen
= len
- copy_from_user(str
, buf
, len
);
2147 while ( rlen
&& str
[rlen
- 1] <= ' ' )
2150 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
2154 if ( stricmp(p
, "clear") == 0 || stricmp(p
, "clear all") == 0
2155 || stricmp(p
, "clean") == 0 || stricmp(p
, "clean all") == 0 ) {
2156 memset(WAN_MIB_TABLE
, 0, sizeof(*WAN_MIB_TABLE
));
2157 g_atm_priv_data
.wrx_pdu
= 0;
2158 g_atm_priv_data
.wrx_drop_pdu
= 0;
2159 g_atm_priv_data
.wtx_pdu
= 0;
2160 g_atm_priv_data
.wtx_err_pdu
= 0;
2161 g_atm_priv_data
.wtx_drop_pdu
= 0;
2167 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
2169 static int proc_read_retx_mib(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2173 printk("Retx FW DTU MIB :\n");
2174 printk(" rx_total_dtu = %u\n", *URETX_RX_TOTAL_DTU
);
2175 printk(" rx_bad_dtu = %u\n", *URETX_RX_BAD_DTU
);
2176 printk(" rx_good_dtu = %u\n", *URETX_RX_GOOD_DTU
);
2177 printk(" rx_corrected_dtu = %u\n", *URETX_RX_CORRECTED_DTU
);
2178 printk(" rx_outofdate_dtu = %u\n", *URETX_RX_OUTOFDATE_DTU
);
2179 printk(" rx_duplicate_dtu = %u\n", *URETX_RX_DUPLICATE_DTU
);
2180 printk(" rx_timeout_dtu = %u\n", *URETX_RX_TIMEOUT_DTU
);
2181 printk(" RxDTURetransmittedCNT = %u\n", *RxDTURetransmittedCNT
);
2184 printk("Retx Standard DTU MIB:\n");
2185 printk(" RxLastEFB = %u\n", *RxLastEFBCNT
);
2186 printk(" RxDTUCorrectedCNT = %u\n", *RxDTUCorrectedCNT
);
2187 printk(" RxDTUCorruptedCNT = %u\n", *RxDTUCorruptedCNT
);
2188 printk(" RxRetxDTUUncorrectedCNT = %u\n", *RxRetxDTUUncorrectedCNT
);
2191 printk("Retx FW Cell MIB :\n");
2192 printk(" bc0_total_cell = %u\n", *WRX_BC0_CELL_NUM
);
2193 printk(" bc0_drop_cell = %u\n", *WRX_BC0_DROP_CELL_NUM
);
2194 printk(" bc0_nonretx_cell = %u\n", *WRX_BC0_NONRETX_CELL_NUM
);
2195 printk(" bc0_retx_cell = %u\n", *WRX_BC0_RETX_CELL_NUM
);
2196 printk(" bc0_outofdate_cell = %u\n", *WRX_BC0_OUTOFDATE_CELL_NUM
);
2197 printk(" bc0_directup_cell = %u\n", *WRX_BC0_DIRECTUP_NUM
);
2198 printk(" bc0_to_pb_total_cell = %u\n", *WRX_BC0_PBW_TOTAL_NUM
);
2199 printk(" bc0_to_pb_succ_cell = %u\n", *WRX_BC0_PBW_SUCC_NUM
);
2200 printk(" bc0_to_pb_fail_cell = %u\n", *WRX_BC0_PBW_FAIL_NUM
);
2201 printk(" bc1_total_cell = %u\n", *WRX_BC1_CELL_NUM
);
2205 printk("ATM Rx AAL5/OAM MIB:\n");
2206 printk(" wrx_drophtu_cell = %u\n", WAN_MIB_TABLE
->wrx_drophtu_cell
);
2207 printk(" wrx_dropdes_pdu = %u\n", WAN_MIB_TABLE
->wrx_dropdes_pdu
);
2209 printk(" wrx_correct_pdu = %-10u ", WAN_MIB_TABLE
->wrx_correct_pdu
);
2210 if ( WAN_MIB_TABLE
->wrx_correct_pdu
== 0 )
2216 for ( i
= 0; i
< 16; ++i
) {
2217 if ( WRX_PER_PVC_CORRECT_PDU_BASE
[i
] )
2218 printk("q%-2d = %-10u , ", i
, WRX_PER_PVC_CORRECT_PDU_BASE
[i
]);
2223 printk(" wrx_err_pdu = %-10u ", WAN_MIB_TABLE
->wrx_err_pdu
);
2224 if ( WAN_MIB_TABLE
->wrx_err_pdu
== 0 )
2230 for ( i
= 0; i
< 16; ++i
) {
2231 if ( WRX_PER_PVC_ERROR_PDU_BASE
[i
] )
2232 printk("q%-2d = %-10u , ", i
, WRX_PER_PVC_ERROR_PDU_BASE
[i
] );
2237 printk(" wrx_dropdes_cell = %u\n", WAN_MIB_TABLE
->wrx_dropdes_cell
);
2238 printk(" wrx_correct_cell = %u\n", WAN_MIB_TABLE
->wrx_correct_cell
);
2239 printk(" wrx_err_cell = %u\n", WAN_MIB_TABLE
->wrx_err_cell
);
2240 printk(" wrx_total_byte = %u\n", WAN_MIB_TABLE
->wrx_total_byte
);
2243 printk("ATM Tx MIB:\n");
2244 printk(" wtx_total_pdu = %u\n", WAN_MIB_TABLE
->wtx_total_pdu
);
2245 printk(" wtx_total_cell = %u\n", WAN_MIB_TABLE
->wtx_total_cell
);
2246 printk(" wtx_total_byte = %u\n", WAN_MIB_TABLE
->wtx_total_byte
);
2249 printk("Debugging Info:\n");
2250 printk(" Firmware version = %d.%d.%d.%d.%d.%d\n",
2251 (int)FW_VER_ID
->family
, (int)FW_VER_ID
->fwtype
, (int)FW_VER_ID
->interface
,
2252 (int)FW_VER_ID
->fwmode
, (int)FW_VER_ID
->major
, (int)FW_VER_ID
->minor
);
2254 printk(" retx_alpha_switch_to_hunt_times = %u\n", *URETX_ALPHA_SWITCH_TO_HUNT_TIMES
);
2263 static int proc_write_retx_mib(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2270 len
= count
< sizeof(str
) ? count
: sizeof(str
) - 1;
2271 rlen
= len
- copy_from_user(str
, buf
, len
);
2272 while ( rlen
&& str
[rlen
- 1] <= ' ' )
2275 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
2279 if ( stricmp(p
, "clean") == 0 || stricmp(p
, "clear") == 0 || stricmp(p
, "clear_all") == 0) {
2280 *URETX_RX_TOTAL_DTU
= 0;
2281 *URETX_RX_BAD_DTU
= 0;
2282 *URETX_RX_GOOD_DTU
= 0;
2283 *URETX_RX_CORRECTED_DTU
= 0;
2284 *URETX_RX_OUTOFDATE_DTU
= 0;
2285 *URETX_RX_DUPLICATE_DTU
= 0;
2286 *URETX_RX_TIMEOUT_DTU
= 0;
2287 *RxDTURetransmittedCNT
= 0;
2289 *WRX_BC0_CELL_NUM
= 0;
2290 *WRX_BC0_DROP_CELL_NUM
= 0;
2291 *WRX_BC0_NONRETX_CELL_NUM
= 0;
2292 *WRX_BC0_RETX_CELL_NUM
= 0;
2293 *WRX_BC0_OUTOFDATE_CELL_NUM
= 0;
2294 *WRX_BC0_DIRECTUP_NUM
= 0;
2295 *WRX_BC0_PBW_TOTAL_NUM
= 0;
2296 *WRX_BC0_PBW_SUCC_NUM
= 0;
2297 *WRX_BC0_PBW_FAIL_NUM
= 0;
2298 *WRX_BC1_CELL_NUM
= 0;
2300 for ( i
= 0; i
< 16; ++i
) {
2301 WRX_PER_PVC_CORRECT_PDU_BASE
[i
] = 0;
2302 WRX_PER_PVC_ERROR_PDU_BASE
[i
] = 0;
2305 WAN_MIB_TABLE
->wrx_drophtu_cell
= 0;
2306 WAN_MIB_TABLE
->wrx_dropdes_pdu
= 0;
2307 WAN_MIB_TABLE
->wrx_correct_pdu
= 0;
2308 WAN_MIB_TABLE
->wrx_err_pdu
= 0;
2309 WAN_MIB_TABLE
->wrx_dropdes_cell
= 0;
2310 WAN_MIB_TABLE
->wrx_correct_cell
= 0;
2311 WAN_MIB_TABLE
->wrx_err_cell
= 0;
2312 WAN_MIB_TABLE
->wrx_total_byte
= 0;
2314 WAN_MIB_TABLE
->wtx_total_pdu
= 0;
2315 WAN_MIB_TABLE
->wtx_total_cell
= 0;
2316 WAN_MIB_TABLE
->wtx_total_byte
= 0;
2318 *URETX_ALPHA_SWITCH_TO_HUNT_TIMES
= 0;
2320 if (stricmp(p
, "clear_all") == 0) {
2322 *RxDTUCorrectedCNT
= 0;
2323 *RxDTUCorruptedCNT
= 0;
2324 *RxRetxDTUUncorrectedCNT
= 0;
2333 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
2335 static int proc_read_dbg(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2339 len
+= sprintf(page
+ off
+ len
, "error print - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_ERR
) ? "enabled" : "disabled");
2340 len
+= sprintf(page
+ off
+ len
, "debug print - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DEBUG_PRINT
) ? "enabled" : "disabled");
2341 len
+= sprintf(page
+ off
+ len
, "assert - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_ASSERT
) ? "enabled" : "disabled");
2342 len
+= sprintf(page
+ off
+ len
, "dump rx skb - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_SKB_RX
) ? "enabled" : "disabled");
2343 len
+= sprintf(page
+ off
+ len
, "dump tx skb - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_SKB_TX
) ? "enabled" : "disabled");
2344 len
+= sprintf(page
+ off
+ len
, "qos - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_QOS
) ? "enabled" : "disabled");
2345 len
+= sprintf(page
+ off
+ len
, "dump init - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_DUMP_INIT
) ? "enabled" : "disabled");
2346 len
+= sprintf(page
+ off
+ len
, "mac swap - %s\n", (ifx_atm_dbg_enable
& DBG_ENABLE_MASK_MAC_SWAP
) ? "enabled" : "disabled");
2353 static int proc_write_dbg(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2355 static const char *dbg_enable_mask_str
[] = {
2374 static const int dbg_enable_mask_str_len
[] = {
2385 unsigned int dbg_enable_mask
[] = {
2386 DBG_ENABLE_MASK_ERR
,
2387 DBG_ENABLE_MASK_DEBUG_PRINT
,
2388 DBG_ENABLE_MASK_ASSERT
,
2389 DBG_ENABLE_MASK_DUMP_SKB_RX
,
2390 DBG_ENABLE_MASK_DUMP_SKB_TX
,
2391 DBG_ENABLE_MASK_DUMP_QOS
,
2392 DBG_ENABLE_MASK_DUMP_INIT
,
2393 DBG_ENABLE_MASK_MAC_SWAP
,
2398 int str_buff_len
= 1024;
2406 str
= vmalloc(str_buff_len
);
2411 len
= count
< str_buff_len
? count
: str_buff_len
- 1;
2412 rlen
= len
- copy_from_user(str
, buf
, len
);
2413 while ( rlen
&& str
[rlen
- 1] <= ' ' )
2416 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
2422 if ( strincmp(p
, "enable", 6) == 0 ) {
2426 else if ( strincmp(p
, "disable", 7) == 0 ) {
2430 else if ( strincmp(p
, "help", 4) == 0 || *p
== '?' ) {
2431 printk("echo <enable/disable> [err/dbg/assert/rx/tx/init/all] > /proc/eth/dbg\n");
2437 ifx_atm_dbg_enable
|= DBG_ENABLE_MASK_ALL
& ~DBG_ENABLE_MASK_MAC_SWAP
;
2439 ifx_atm_dbg_enable
&= ~DBG_ENABLE_MASK_ALL
| DBG_ENABLE_MASK_MAC_SWAP
;
2443 for ( i
= 0; i
< NUM_ENTITY(dbg_enable_mask_str
); i
++ )
2444 if ( strincmp(p
, dbg_enable_mask_str
[i
], dbg_enable_mask_str_len
[i
]) == 0 ) {
2446 ifx_atm_dbg_enable
|= dbg_enable_mask
[i
>> 1];
2448 ifx_atm_dbg_enable
&= ~dbg_enable_mask
[i
>> 1];
2449 p
+= dbg_enable_mask_str_len
[i
];
2452 } while ( i
< NUM_ENTITY(dbg_enable_mask_str
) );
2460 static inline unsigned long sb_addr_to_fpi_addr_convert(unsigned long sb_addr
)
2462 #define PP32_SB_ADDR_END 0xFFFF
2464 if ( sb_addr
< PP32_SB_ADDR_END
)
2465 return (unsigned long)SB_BUFFER(sb_addr
);
2470 static int proc_write_mem(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2477 int local_buf_size
= 1024;
2478 char *local_buf
= NULL
;
2480 local_buf
= vmalloc(local_buf_size
);
2485 len
= local_buf_size
< count
? local_buf_size
- 1 : count
;
2486 len
= len
- copy_from_user(local_buf
, buf
, len
);
2491 while ( get_token(&p1
, &p2
, &len
, &colon
) ) {
2492 if ( stricmp(p1
, "w") == 0 || stricmp(p1
, "write") == 0 || stricmp(p1
, "r") == 0 || stricmp(p1
, "read") == 0 )
2500 ignore_space(&p2
, &len
);
2501 p
= (unsigned long *)get_number(&p2
, &len
, 1);
2502 p
= (unsigned long *)sb_addr_to_fpi_addr_convert((unsigned long)p
);
2504 if ( (unsigned int)p
>= KSEG0
)
2506 ignore_space(&p2
, &len
);
2507 if ( !len
|| !((*p2
>= '0' && *p2
<= '9') || (*p2
>= 'a' && *p2
<= 'f') || (*p2
>= 'A' && *p2
<= 'F')) )
2510 *p
++ = (unsigned int)get_number(&p2
, &len
, 1);
2513 else if ( *p1
== 'r' ) {
2514 ignore_space(&p2
, &len
);
2515 p
= (unsigned long *)get_number(&p2
, &len
, 1);
2516 p
= (unsigned long *)sb_addr_to_fpi_addr_convert((unsigned long)p
);
2518 if ( (unsigned int)p
>= KSEG0
) {
2519 ignore_space(&p2
, &len
);
2520 n
= (int)get_number(&p2
, &len
, 0);
2528 n
+= (l
= ((int)p
>> 2) & 0x03);
2529 p
= (unsigned long *)((unsigned int)p
& ~0x0F);
2530 for ( i
= 0; i
< n
; i
++ ) {
2531 if ( (i
& 0x03) == 0 ) {
2532 printk("%08X:", (unsigned int)p
);
2540 data
= (unsigned int)*p
;
2541 printk(" %08X", data
);
2542 for ( k
= 0; k
< 4; k
++ ) {
2543 c
= ((char*)&data
)[k
];
2544 pch
[k
] = c
< ' ' ? '.' : c
;
2549 if ( (i
& 0x03) == 0x03 ) {
2551 printk(" ; %s\n", str
);
2554 if ( (n
& 0x03) != 0x00 ) {
2555 for ( k
= 4 - (n
& 0x03); k
> 0; k
-- )
2558 printk(" ; %s\n", str
);
2568 #if defined(CONFIG_AR9) || defined(CONFIG_VR9)
2570 static int proc_read_pp32(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2572 static const char *stron
= " on";
2573 static const char *stroff
= "off";
2584 for ( pp32
= 0; pp32
< NUM_OF_PP32
; pp32
++ ) {
2587 len
+= sprintf(page
+ off
+ len
, "===== pp32 core %d =====\n", pp32
);
2590 if ( (*PP32_FREEZE
& (1 << (pp32
<< 4))) != 0 ) {
2591 sprintf(str
, "freezed");
2598 else if ( PP32_CPU_USER_STOPPED(pp32
) || PP32_CPU_USER_BREAKIN_RCV(pp32
) || PP32_CPU_USER_BREAKPOINT_MET(pp32
) ) {
2600 if ( PP32_CPU_USER_STOPPED(pp32
) )
2601 strlength
+= sprintf(str
+ strlength
, "stopped");
2602 if ( PP32_CPU_USER_BREAKPOINT_MET(pp32
) )
2603 strlength
+= sprintf(str
+ strlength
, strlength
? " | breakpoint" : "breakpoint");
2604 if ( PP32_CPU_USER_BREAKIN_RCV(pp32
) )
2605 strlength
+= sprintf(str
+ strlength
, strlength
? " | breakin" : "breakin");
2609 else if ( PP32_CPU_CUR_PC(pp32
) == PP32_CPU_CUR_PC(pp32
) ) {
2610 sprintf(str
, "hang");
2615 sprintf(str
, "running");
2616 cur_context
= PP32_BRK_CUR_CONTEXT(pp32
);
2617 len
+= sprintf(page
+ off
+ len
, "Context: %d, PC: 0x%04x, %s\n", cur_context
, PP32_CPU_CUR_PC(pp32
), str
);
2619 if ( PP32_CPU_USER_BREAKPOINT_MET(pp32
) ) {
2621 if ( PP32_BRK_PC_MET(pp32
, 0) )
2622 strlength
+= sprintf(str
+ strlength
, "pc0");
2623 if ( PP32_BRK_PC_MET(pp32
, 1) )
2624 strlength
+= sprintf(str
+ strlength
, strlength
? " | pc1" : "pc1");
2625 if ( PP32_BRK_DATA_ADDR_MET(pp32
, 0) )
2626 strlength
+= sprintf(str
+ strlength
, strlength
? " | daddr0" : "daddr0");
2627 if ( PP32_BRK_DATA_ADDR_MET(pp32
, 1) )
2628 strlength
+= sprintf(str
+ strlength
, strlength
? " | daddr1" : "daddr1");
2629 if ( PP32_BRK_DATA_VALUE_RD_MET(pp32
, 0) ) {
2630 strlength
+= sprintf(str
+ strlength
, strlength
? " | rdval0" : "rdval0");
2631 if ( PP32_BRK_DATA_VALUE_RD_LO_EQ(pp32
, 0) ) {
2632 if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32
, 0) )
2633 strlength
+= sprintf(str
+ strlength
, " ==");
2635 strlength
+= sprintf(str
+ strlength
, " <=");
2637 else if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32
, 0) )
2638 strlength
+= sprintf(str
+ strlength
, " >=");
2640 if ( PP32_BRK_DATA_VALUE_RD_MET(pp32
, 1) ) {
2641 strlength
+= sprintf(str
+ strlength
, strlength
? " | rdval1" : "rdval1");
2642 if ( PP32_BRK_DATA_VALUE_RD_LO_EQ(pp32
, 1) ) {
2643 if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32
, 1) )
2644 strlength
+= sprintf(str
+ strlength
, " ==");
2646 strlength
+= sprintf(str
+ strlength
, " <=");
2648 else if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32
, 1) )
2649 strlength
+= sprintf(str
+ strlength
, " >=");
2651 if ( PP32_BRK_DATA_VALUE_WR_MET(pp32
, 0) ) {
2652 strlength
+= sprintf(str
+ strlength
, strlength
? " | wtval0" : "wtval0");
2653 if ( PP32_BRK_DATA_VALUE_WR_LO_EQ(pp32
, 0) ) {
2654 if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32
, 0) )
2655 strlength
+= sprintf(str
+ strlength
, " ==");
2657 strlength
+= sprintf(str
+ strlength
, " <=");
2659 else if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32
, 0) )
2660 strlength
+= sprintf(str
+ strlength
, " >=");
2662 if ( PP32_BRK_DATA_VALUE_WR_MET(pp32
, 1) ) {
2663 strlength
+= sprintf(str
+ strlength
, strlength
? " | wtval1" : "wtval1");
2664 if ( PP32_BRK_DATA_VALUE_WR_LO_EQ(pp32
, 1) ) {
2665 if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32
, 1) )
2666 strlength
+= sprintf(str
+ strlength
, " ==");
2668 strlength
+= sprintf(str
+ strlength
, " <=");
2670 else if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32
, 1) )
2671 strlength
+= sprintf(str
+ strlength
, " >=");
2673 len
+= sprintf(page
+ off
+ len
, "break reason: %s\n", str
);
2678 len
+= sprintf(page
+ off
+ len
, "General Purpose Register (Context %d):\n", cur_context
);
2679 for ( i
= 0; i
< 4; i
++ ) {
2680 for ( j
= 0; j
< 4; j
++ )
2681 len
+= sprintf(page
+ off
+ len
, " %2d: %08x", i
+ j
* 4, *PP32_GP_CONTEXTi_REGn(pp32
, cur_context
, i
+ j
* 4));
2682 len
+= sprintf(page
+ off
+ len
, "\n");
2686 len
+= sprintf(page
+ off
+ len
, "break out on: break in - %s, stop - %s\n",
2687 PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(pp32
) ? stron
: stroff
,
2688 PP32_CTRL_OPT_BREAKOUT_ON_STOP(pp32
) ? stron
: stroff
);
2689 len
+= sprintf(page
+ off
+ len
, " stop on: break in - %s, break point - %s\n",
2690 PP32_CTRL_OPT_STOP_ON_BREAKIN(pp32
) ? stron
: stroff
,
2691 PP32_CTRL_OPT_STOP_ON_BREAKPOINT(pp32
) ? stron
: stroff
);
2692 len
+= sprintf(page
+ off
+ len
, "breakpoint:\n");
2693 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");
2694 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");
2695 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");
2696 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");
2697 len
+= sprintf(page
+ off
+ len
, " rdval0: 0x%08x\n", *PP32_BRK_DATA_VALUE_RD(pp32
, 0));
2698 len
+= sprintf(page
+ off
+ len
, " rdval1: 0x%08x\n", *PP32_BRK_DATA_VALUE_RD(pp32
, 1));
2699 len
+= sprintf(page
+ off
+ len
, " wrval0: 0x%08x\n", *PP32_BRK_DATA_VALUE_WR(pp32
, 0));
2700 len
+= sprintf(page
+ off
+ len
, " wrval1: 0x%08x\n", *PP32_BRK_DATA_VALUE_WR(pp32
, 1));
2708 static int proc_write_pp32(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2713 int str_buff_len
= 1024;
2719 str
= vmalloc(str_buff_len
);
2724 len
= count
< str_buff_len
? count
: str_buff_len
- 1;
2725 rlen
= len
- copy_from_user(str
, buf
, len
);
2726 while ( rlen
&& str
[rlen
- 1] <= ' ' )
2729 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
2735 if ( strincmp(p
, "pp32 ", 5) == 0 ) {
2739 while ( rlen
> 0 && *p
>= '0' && *p
<= '9' ) {
2744 while ( rlen
> 0 && *p
&& *p
<= ' ' ) {
2749 if ( pp32
>= NUM_OF_PP32
) {
2750 err("incorrect pp32 index - %d", pp32
);
2756 if ( stricmp(p
, "start") == 0 )
2757 *PP32_CTRL_CMD(pp32
) = PP32_CTRL_CMD_RESTART
;
2758 else if ( stricmp(p
, "stop") == 0 )
2759 *PP32_CTRL_CMD(pp32
) = PP32_CTRL_CMD_STOP
;
2760 else if ( stricmp(p
, "step") == 0 )
2761 *PP32_CTRL_CMD(pp32
) = PP32_CTRL_CMD_STEP
;
2763 else if ( stricmp(p
, "restart") == 0 )
2764 *PP32_FREEZE
&= ~(1 << (pp32
<< 4));
2765 else if ( stricmp(p
, "freeze") == 0 )
2766 *PP32_FREEZE
|= 1 << (pp32
<< 4);
2768 else if ( strincmp(p
, "pc0 ", 4) == 0 ) {
2771 if ( stricmp(p
, "off") == 0 ) {
2772 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_PCn_OFF(0, 0);
2773 *PP32_BRK_PC_MASK(pp32
, 0) = PP32_BRK_CONTEXT_MASK_EN
;
2774 *PP32_BRK_PC(pp32
, 0) = 0;
2777 addr
= get_number(&p
, &rlen
, 1);
2778 *PP32_BRK_PC(pp32
, 0) = addr
;
2779 *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);
2780 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_PCn_ON(0, 0);
2783 else if ( strincmp(p
, "pc1 ", 4) == 0 ) {
2786 if ( stricmp(p
, "off") == 0 ) {
2787 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_PCn_OFF(1, 1);
2788 *PP32_BRK_PC_MASK(pp32
, 1) = PP32_BRK_CONTEXT_MASK_EN
;
2789 *PP32_BRK_PC(pp32
, 1) = 0;
2792 addr
= get_number(&p
, &rlen
, 1);
2793 *PP32_BRK_PC(pp32
, 1) = addr
;
2794 *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);
2795 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_PCn_ON(1, 1);
2798 else if ( strincmp(p
, "daddr0 ", 7) == 0 ) {
2801 if ( stricmp(p
, "off") == 0 ) {
2802 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_DATA_ADDRn_OFF(0, 0);
2803 *PP32_BRK_DATA_ADDR_MASK(pp32
, 0) = PP32_BRK_CONTEXT_MASK_EN
;
2804 *PP32_BRK_DATA_ADDR(pp32
, 0) = 0;
2807 addr
= get_number(&p
, &rlen
, 1);
2808 *PP32_BRK_DATA_ADDR(pp32
, 0) = addr
;
2809 *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);
2810 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_DATA_ADDRn_ON(0, 0);
2813 else if ( strincmp(p
, "daddr1 ", 7) == 0 ) {
2816 if ( stricmp(p
, "off") == 0 ) {
2817 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_DATA_ADDRn_OFF(1, 1);
2818 *PP32_BRK_DATA_ADDR_MASK(pp32
, 1) = PP32_BRK_CONTEXT_MASK_EN
;
2819 *PP32_BRK_DATA_ADDR(pp32
, 1) = 0;
2822 addr
= get_number(&p
, &rlen
, 1);
2823 *PP32_BRK_DATA_ADDR(pp32
, 1) = addr
;
2824 *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);
2825 *PP32_BRK_TRIG(pp32
) = PP32_BRK_GRPi_DATA_ADDRn_ON(1, 1);
2830 printk("echo \"<command>\" > /proc/driver/ifx_ptm/pp32\n");
2831 printk(" command:\n");
2832 printk(" start - run pp32\n");
2833 printk(" stop - stop pp32\n");
2834 printk(" step - run pp32 with one step only\n");
2835 printk(" pc0 - pc0 <addr>/off, set break point PC0\n");
2836 printk(" pc1 - pc1 <addr>/off, set break point PC1\n");
2837 printk(" daddr0 - daddr0 <addr>/off, set break point data address 0\n");
2838 printk(" daddr0 - daddr1 <addr>/off, set break point data address 1\n");
2839 printk(" help - print this screen\n");
2842 if ( *PP32_BRK_TRIG(pp32
) )
2843 *PP32_CTRL_OPT(pp32
) = PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON
;
2845 *PP32_CTRL_OPT(pp32
) = PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF
;
2850 #elif defined(CONFIG_DANUBE)
2852 static int proc_read_pp32(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2854 static const char *halt_stat
[] = {
2863 static const char *brk_src_data
[] = {
2873 static const char *brk_src_code
[] = {
2884 tsk
= *PP32_DBG_TASK_NO
& 0x03;
2885 len
+= sprintf(page
+ off
+ len
, "Task No %d, PC %04x\n", tsk
, *PP32_DBG_CUR_PC
& 0xFFFF);
2887 if ( !(*PP32_HALT_STAT
& 0x01) )
2888 len
+= sprintf(page
+ off
+ len
, " Halt State: Running\n");
2890 len
+= sprintf(page
+ off
+ len
, " Halt State: Stopped");
2892 for ( bit
= 2, i
= 0; bit
<= (1 << 7); bit
<<= 1, i
++ )
2893 if ( (*PP32_HALT_STAT
& bit
) ) {
2895 len
+= sprintf(page
+ off
+ len
, ", ");
2899 len
+= sprintf(page
+ off
+ len
, " | ");
2900 len
+= sprintf(page
+ off
+ len
, halt_stat
[i
]);
2903 len
+= sprintf(page
+ off
+ len
, "\n");
2905 len
+= sprintf(page
+ off
+ len
, " Regs (Task %d):\n", tsk
);
2906 for ( i
= 0; i
< 8; i
++ )
2907 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));
2910 len
+= sprintf(page
+ off
+ len
, " Break Src: data1 - %s, data0 - %s, pc3 - %s, pc2 - %s, pc1 - %s, pc0 - %s\n",
2911 brk_src_data
[(*PP32_BRK_SRC
>> 11) & 0x07],
2912 brk_src_data
[(*PP32_BRK_SRC
>> 8) & 0x07],
2913 brk_src_code
[(*PP32_BRK_SRC
>> 3) & 0x01],
2914 brk_src_code
[(*PP32_BRK_SRC
>> 2) & 0x01],
2915 brk_src_code
[(*PP32_BRK_SRC
>> 1) & 0x01],
2916 brk_src_code
[*PP32_BRK_SRC
& 0x01]);
2918 for ( i
= 0; i
< 4; i
++ )
2919 len
+= sprintf(page
+ off
+ len
, " pc%d: %04x - %04x\n", i
, *PP32_DBG_PC_MIN(i
), *PP32_DBG_PC_MAX(i
));
2921 for ( i
= 0; i
< 2; i
++ )
2922 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
));
2929 static int proc_write_pp32(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
2935 int str_buff_len
= 2048;
2936 str
= vmalloc(str_buff_len
);
2940 len
= count
< str_buff_len
? count
: str_buff_len
- 1;
2941 rlen
= len
- copy_from_user(str
, buf
, len
);
2942 while ( rlen
&& str
[rlen
- 1] <= ' ' )
2945 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
2950 if ( stricmp(p
, "start") == 0 )
2951 *PP32_DBG_CTRL
= DBG_CTRL_START_SET(1);
2952 else if ( stricmp(p
, "stop") == 0 )
2953 *PP32_DBG_CTRL
= DBG_CTRL_STOP_SET(1);
2954 else if ( stricmp(p
, "step") == 0 )
2955 *PP32_DBG_CTRL
= DBG_CTRL_STEP_SET(1);
2956 else if ( strincmp(p
, "pc", 2) == 0 && p
[2] >= '0' && p
[2] <= '3' && p
[3] <= ' ' ) {
2958 int on_off_flag
= -1;
2959 int addr_min
, addr_max
;
2963 ignore_space(&p
, &rlen
);
2965 if ( strincmp(p
, "off", 3) == 0 && p
[3] <= ' ' ) {
2970 else if ( strincmp(p
, "on", 2) == 0 && p
[2] <= ' ' ) {
2975 ignore_space(&p
, &rlen
);
2978 addr_min
= get_number(&p
, &rlen
, 1);
2979 ignore_space(&p
, &rlen
);
2981 addr_max
= get_number(&p
, &rlen
, 1);
2983 addr_max
= addr_min
;
2985 *PP32_DBG_PC_MIN(n
) = addr_min
;
2986 *PP32_DBG_PC_MAX(n
) = addr_max
;
2989 if ( on_off_flag
== 0 )
2990 *PP32_BRK_SRC
&= ~(1 << n
);
2991 else if ( on_off_flag
> 0 )
2992 *PP32_BRK_SRC
|= 1 << n
;
2994 else if ( strincmp(p
, "data", 4) == 0 && p
[4] >= '0' && p
[4] <= '1' && p
[5] <= ' ' ) {
2995 const static char *data_cmd_str
[] = {"r", "w", "rw", "w=", "off", "min", "min addr", "max", "max addr", "val", "value"};
2996 const static int data_cmd_len
[] = {1, 1, 2, 2, 3, 3, 8, 3, 8, 3, 5};
2997 const static int data_cmd_idx
[] = {1, 2, 3, 4, 0, 5, 5, 6, 6, 7, 7};
2999 int on_off_flag
= -1, on_off_mask
= 0;
3000 int addr_min
= -1, addr_max
= -1;
3001 int value
= 0, f_got_value
= 0;
3010 ignore_space(&p
, &rlen
);
3013 for ( i
= 0; i
< NUM_ENTITY(data_cmd_str
); i
++ )
3014 if ( strincmp(p
, data_cmd_str
[i
], data_cmd_len
[i
]) == 0 && p
[data_cmd_len
[i
]] <= ' ' ) {
3015 p
+= data_cmd_len
[i
];
3016 rlen
-= data_cmd_len
[i
];
3017 stat
= data_cmd_idx
[i
];
3024 if ( i
== NUM_ENTITY(data_cmd_str
) ) {
3025 if ( (*p
>= '0' && *p
<= '9') || (*p
>= 'a' && *p
<= 'f') || (*p
>= 'A' && *p
<= 'F') ) {
3026 tmp
= get_number(&p
, &rlen
, 1);
3031 else if ( stat
>= 7 ) {
3041 for ( ; rlen
&& *p
> ' '; rlen
--, p
++ );
3045 if ( addr_min
>= 0 )
3046 *PP32_DBG_DATA_MIN(n
) = *PP32_DBG_DATA_MAX(n
) = addr_min
;
3047 if ( addr_max
>= 0 )
3048 *PP32_DBG_DATA_MAX(n
) = addr_max
;
3050 *PP32_DBG_DATA_VAL(n
) = value
;
3051 if ( on_off_mask
&& on_off_flag
>= 0 ) {
3052 on_off_flag
<<= n
? 11 : 8;
3053 on_off_mask
<<= n
? 11 : 8;
3054 *PP32_BRK_SRC
= (*PP32_BRK_SRC
& ~on_off_mask
) | on_off_flag
;
3058 printk("echo \"<command>\" > /proc/eth/etop\n");
3059 printk(" command:\n");
3060 printk(" start - run pp32\n");
3061 printk(" stop - stop pp32\n");
3062 printk(" step - run pp32 with one step only\n");
3063 printk(" pc - pc? [on/off] [min addr] [max addr], set PC break point\n");
3064 printk(" data - data? [r/w/rw/w=/off] [min <addr>] [max <addr>] [val <value>], set data break point\n");
3065 printk(" help - print this screen\n");
3072 #elif defined(CONFIG_AMAZON_SE)
3074 static int proc_read_pp32(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3076 static const char *halt_stat
[] = {
3085 static const char *brk_src_data
[] = {
3095 static const char *brk_src_code
[] = {
3105 len
+= sprintf(page
+ off
+ len
, "Task No %d, PC %04x\n", *PP32_DBG_TASK_NO
& 0x03, *PP32_DBG_CUR_PC
& 0xFFFF);
3107 if ( !(*PP32_HALT_STAT
& 0x01) )
3108 len
+= sprintf(page
+ off
+ len
, " Halt State: Running\n");
3111 len
+= sprintf(page
+ off
+ len
, " Halt State: Stopped");
3113 for ( bit
= 2, i
= 0; bit
<= (1 << 7); bit
<<= 1, i
++ )
3114 if ( (*PP32_HALT_STAT
& bit
) )
3118 len
+= sprintf(page
+ off
+ len
, ", ");
3122 len
+= sprintf(page
+ off
+ len
, " | ");
3123 len
+= sprintf(page
+ off
+ len
, halt_stat
[i
]);
3126 len
+= sprintf(page
+ off
+ len
, "\n");
3129 len
+= sprintf(page
+ off
+ len
, " Break Src: data1 - %s, data0 - %s, pc3 - %s, pc2 - %s, pc1 - %s, pc0 - %s\n",
3130 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]);
3132 // for ( i = 0; i < 4; i++ )
3133 // len += sprintf(page + off + len, " pc%d: %04x - %04x\n", i, *PP32_DBG_PC_MIN(i), *PP32_DBG_PC_MAX(i));
3135 // for ( i = 0; i < 2; i++ )
3136 // 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));
3143 static int proc_write_pp32(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
3150 len
= count
< sizeof(str
) ? count
: sizeof(str
) - 1;
3151 rlen
= len
- copy_from_user(str
, buf
, len
);
3152 while ( rlen
&& str
[rlen
- 1] <= ' ' )
3155 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
3159 if ( stricmp(str
, "start") == 0 )
3160 *PP32_DBG_CTRL
= DBG_CTRL_RESTART
;
3161 else if ( stricmp(str
, "stop") == 0 )
3162 *PP32_DBG_CTRL
= DBG_CTRL_STOP
;
3163 // else if ( stricmp(str, "step") == 0 )
3164 // *PP32_DBG_CTRL = DBG_CTRL_STEP_SET(1);
3167 printk("echo \"<command>\" > /proc/eth/etop\n");
3168 printk(" command:\n");
3169 printk(" start - run pp32\n");
3170 printk(" stop - stop pp32\n");
3171 // printk(" step - run pp32 with one step only\n");
3172 printk(" help - print this screen\n");
3182 #if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
3184 static INLINE
int print_htu(char *buf
, int i
)
3188 if ( HTU_ENTRY(i
)->vld
) {
3189 len
+= sprintf(buf
+ len
, "%2d. valid\n", i
);
3190 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
);
3191 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
);
3192 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
);
3193 if ( HTU_RESULT(i
)->type
)
3194 len
+= sprintf(buf
+ len
, ", cell id: %d, verification: %s", HTU_RESULT(i
)->cellid
, HTU_RESULT(i
)->ven
? "on" : "off");
3195 len
+= sprintf(buf
+ len
, "\n");
3198 len
+= sprintf(buf
+ len
, "%2d. invalid\n", i
);
3203 static int proc_read_htu(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3206 int len_max
= off
+ count
;
3210 int htuts
= *CFG_WRX_HTUTS
;
3213 str
= vmalloc (1024);
3217 pstr
= *start
= page
;
3219 llen
= sprintf(pstr
, "HTU Table (Max %d):\n", htuts
);
3223 for ( i
= 0; i
< htuts
; i
++ ) {
3224 llen
= print_htu(str
, i
);
3225 if ( len
<= off
&& len
+ llen
> off
) {
3226 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3227 pstr
+= len
+ llen
- off
;
3229 else if ( len
> off
) {
3230 memcpy(pstr
, str
, llen
);
3234 if ( len
>= len_max
)
3235 goto PROC_READ_HTU_OVERRUN_END
;
3242 PROC_READ_HTU_OVERRUN_END
:
3244 return len
- llen
- off
;
3247 static INLINE
int print_tx_queue(char *buf
, int i
)
3251 if ( (*WTX_DMACH_ON
& (1 << i
)) ) {
3252 len
+= sprintf(buf
+ len
, "%2d. valid\n", i
);
3253 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");
3254 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
);
3257 len
+= sprintf(buf
+ len
, "%2d. invalid\n", i
);
3262 static int proc_read_txq(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3265 int len_max
= off
+ count
;
3268 int str_buff_len
= 1024;
3273 str
= vmalloc(str_buff_len
);
3277 pstr
= *start
= page
;
3279 llen
= sprintf(pstr
, "TX Queue Config (Max %d):\n", *CFG_WTX_DCHNUM
);
3283 for ( i
= 0; i
< 16; i
++ ) {
3284 llen
= print_tx_queue(str
, i
);
3285 if ( len
<= off
&& len
+ llen
> off
) {
3286 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3287 pstr
+= len
+ llen
- off
;
3289 else if ( len
> off
) {
3290 memcpy(pstr
, str
, llen
);
3294 if ( len
>= len_max
)
3295 goto PROC_READ_HTU_OVERRUN_END
;
3304 PROC_READ_HTU_OVERRUN_END
:
3306 return len
- llen
- off
;
3309 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
3311 static int proc_read_retx_fw(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3315 unsigned int next_dtu_sid_out
, last_dtu_sid_in
, next_cell_sid_out
, isr_cell_id
;
3316 unsigned int curr_time
, sec_counter
, curr_efb
;
3317 struct Retx_adsl_ppe_intf adsl_ppe_intf
;
3319 adsl_ppe_intf
= *RETX_ADSL_PPE_INTF
;
3320 next_dtu_sid_out
= *NEXT_DTU_SID_OUT
;
3321 last_dtu_sid_in
= *LAST_DTU_SID_IN
;
3322 next_cell_sid_out
= *NEXT_CELL_SID_OUT
;
3323 isr_cell_id
= *ISR_CELL_ID
;
3325 curr_time
= *URetx_curr_time
;
3326 sec_counter
= *URetx_sec_counter
;
3327 curr_efb
= *RxCURR_EFB
;
3330 len
+= sprintf(page
+ off
+ len
, "Adsl-PPE Interface:\n");
3331 len
+= sprintf(page
+ off
+ len
, " dtu_sid = 0x%02x [%3u]\n", adsl_ppe_intf
.dtu_sid
, adsl_ppe_intf
.dtu_sid
);
3332 len
+= sprintf(page
+ off
+ len
, " dtu_timestamp = 0x%02x\n", adsl_ppe_intf
.dtu_timestamp
);
3333 len
+= sprintf(page
+ off
+ len
, " local_time = 0x%02x\n", adsl_ppe_intf
.local_time
);
3334 len
+= sprintf(page
+ off
+ len
, " is_last_cw = %u\n", adsl_ppe_intf
.is_last_cw
);
3335 len
+= sprintf(page
+ off
+ len
, " reinit_flag = %u\n", adsl_ppe_intf
.reinit_flag
);
3336 len
+= sprintf(page
+ off
+ len
, " is_bad_cw = %u\n", adsl_ppe_intf
.is_bad_cw
);
3337 len
+= sprintf(page
+ off
+ len
, "\n");
3340 len
+= sprintf(page
+ off
+ len
, "Retx Firmware Context:\n");
3341 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
);
3342 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
);
3343 len
+= sprintf(page
+ off
+ len
, " next_cell_sid_out (0x%08x) = %u\n", (unsigned int )NEXT_CELL_SID_OUT
, next_cell_sid_out
);
3344 len
+= sprintf(page
+ off
+ len
, " isr_cell_id (0x%08x) = %u\n", (unsigned int )ISR_CELL_ID
, isr_cell_id
);
3345 len
+= sprintf(page
+ off
+ len
, " pb_cell_search_idx (0x%08x) = %u\n", (unsigned int )PB_CELL_SEARCH_IDX
, *PB_CELL_SEARCH_IDX
);
3346 len
+= sprintf(page
+ off
+ len
, " pb_read_pend_flag (0x%08x) = %u\n", (unsigned int )PB_READ_PEND_FLAG
, *PB_READ_PEND_FLAG
);
3347 len
+= sprintf(page
+ off
+ len
, " rfbi_first_cw (0x%08x) = %u\n", (unsigned int )RFBI_FIRST_CW
, *RFBI_FIRST_CW
);
3348 len
+= sprintf(page
+ off
+ len
, " rfbi_bad_cw (0x%08x) = %u\n", (unsigned int )RFBI_BAD_CW
, *RFBI_BAD_CW
);
3349 len
+= sprintf(page
+ off
+ len
, " rfbi_invalid_cw (0x%08x) = %u\n", (unsigned int )RFBI_INVALID_CW
, *RFBI_INVALID_CW
);
3350 len
+= sprintf(page
+ off
+ len
, " rfbi_retx_cw (0x%08x) = %u\n", (unsigned int )RFBI_RETX_CW
, *RFBI_RETX_CW
);
3351 len
+= sprintf(page
+ off
+ len
, " rfbi_chk_dtu_status (0x%08x) = %u\n", (unsigned int )RFBI_CHK_DTU_STATUS
,*RFBI_CHK_DTU_STATUS
);
3352 len
+= sprintf(page
+ off
+ len
, "\n");
3355 len
+= sprintf(page
+ off
+ len
, "SFSM Status: bc0 bc1 \n\n");
3356 len
+= sprintf(page
+ off
+ len
, " state = %-22s , %s\n",
3357 (*__WRXCTXT_PortState(0) & 3) == 0 ? "Hunt" :
3358 (*__WRXCTXT_PortState(0) & 3) == 1 ? "Pre_sync" :
3359 (*__WRXCTXT_PortState(0) & 3) == 2 ? "Sync" :
3361 (*__WRXCTXT_PortState(1) & 3) == 0 ? "Hunt" :
3362 (*__WRXCTXT_PortState(1) & 3) == 1 ? "Pre_sync" :
3363 (*__WRXCTXT_PortState(1) & 3) == 2 ? "Sync" :
3365 len
+= sprintf(page
+ off
+ len
, " dbase = 0x%04x ( 0x%08x ) , 0x%04x ( 0x%08x )\n",
3366 SFSM_DBA(0)->dbase
, (unsigned int)PPM_INT_UNIT_ADDR(SFSM_DBA(0)->dbase
+ 0x2000),
3367 SFSM_DBA(1)->dbase
, (unsigned int)PPM_INT_UNIT_ADDR(SFSM_DBA(1)->dbase
+ 0x2000));
3368 len
+= sprintf(page
+ off
+ len
, " cbase = 0x%04x ( 0x%08x ) , 0x%04x ( 0x%08x )\n",
3369 SFSM_CBA(0)->cbase
, (unsigned int)PPM_INT_UNIT_ADDR(SFSM_CBA(0)->cbase
+ 0x2000),
3370 SFSM_CBA(1)->cbase
, (unsigned int)PPM_INT_UNIT_ADDR(SFSM_CBA(1)->cbase
+ 0x2000));
3371 len
+= sprintf(page
+ off
+ len
, " sen = %-22d , %d\n", SFSM_CFG(0)->sen
, SFSM_CFG(1)->sen
);
3372 len
+= sprintf(page
+ off
+ len
, " idlekeep = %-22d , %d\n", SFSM_CFG(0)->idlekeep
, SFSM_CFG(1)->idlekeep
);
3373 len
+= sprintf(page
+ off
+ len
, " pnum = %-22d , %d\n", SFSM_CFG(0)->pnum
, SFSM_CFG(1)->pnum
);
3374 len
+= sprintf(page
+ off
+ len
, " pptr = %-22d , %d\n", SFSM_PGCNT(0)->pptr
, SFSM_PGCNT(1)->pptr
);
3375 len
+= sprintf(page
+ off
+ len
, " upage = %-22d , %d\n", SFSM_PGCNT(0)->upage
, SFSM_PGCNT(1)->upage
);
3376 len
+= sprintf(page
+ off
+ len
, " l2_rdptr = %-22d , %d\n", *__WRXCTXT_L2_RdPtr(0), *__WRXCTXT_L2_RdPtr(1) );
3377 len
+= sprintf(page
+ off
+ len
, " l2_page = %-22d , %d\n", *__WRXCTXT_L2Pages(0), *__WRXCTXT_L2Pages(1) );
3378 len
+= sprintf(page
+ off
+ len
, "\n");
3381 len
+= sprintf(page
+ off
+ len
, "FFSM Status: bc0 bc1 \n\n");
3382 len
+= sprintf(page
+ off
+ len
, " dbase = 0x%04x ( 0x%08x ) , 0x%04x ( 0x%08x )\n",
3383 FFSM_DBA(0)->dbase
, (unsigned int)PPM_INT_UNIT_ADDR(FFSM_DBA(0)->dbase
+ 0x2000),
3384 FFSM_DBA(1)->dbase
, (unsigned int)PPM_INT_UNIT_ADDR(FFSM_DBA(1)->dbase
+ 0x2000));
3385 len
+= sprintf(page
+ off
+ len
, " pnum = %-22d , %d\n", FFSM_CFG(0)->pnum
, FFSM_CFG(1)->pnum
);
3386 len
+= sprintf(page
+ off
+ len
, " vpage = %-22d , %d\n", FFSM_PGCNT(0)->vpage
, FFSM_PGCNT(1)->vpage
);
3387 len
+= sprintf(page
+ off
+ len
, " ival = %-22d , %d\n", FFSM_PGCNT(0)->ival
, FFSM_PGCNT(1)->ival
);
3388 len
+= sprintf(page
+ off
+ len
, " tc_wrptr = %-22d , %d\n", *__WTXCTXT_TC_WRPTR(0), *__WTXCTXT_TC_WRPTR(1));
3389 len
+= sprintf(page
+ off
+ len
, "\n");
3392 len
+= sprintf(page
+ off
+ len
, "Misc: \n\n");
3393 len
+= sprintf(page
+ off
+ len
, " curr_time = %08x\n", curr_time
);
3394 len
+= sprintf(page
+ off
+ len
, " sec_counter = %d\n", sec_counter
);
3395 len
+= sprintf(page
+ off
+ len
, " curr_efb = %d\n", curr_efb
);
3396 len
+= sprintf(page
+ off
+ len
, "\n");
3403 static inline int is_valid(unsigned int * dtu_vld_stat
, int dtu_sid
)
3405 int dw_idx
= (dtu_sid
/ 32) & 7;
3406 int bit_pos
= dtu_sid
% 32;
3408 return dtu_vld_stat
[dw_idx
] & (0x80000000 >> bit_pos
);
3411 static int proc_read_retx_stats(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3415 int len_max
= off
+ count
;
3420 unsigned int next_dtu_sid_out
, last_dtu_sid_in
, next_cell_sid_out
;
3421 unsigned int dtu_vld_stat
[8];
3422 struct DTU_stat_info dtu_stat_info
[256];
3423 struct Retx_adsl_ppe_intf adsl_ppe_intf
;
3425 pstr
= *start
= page
;
3429 // capture a snapshot of internal status
3430 next_dtu_sid_out
= *NEXT_DTU_SID_OUT
;
3431 last_dtu_sid_in
= *LAST_DTU_SID_IN
;
3432 next_cell_sid_out
= *NEXT_CELL_SID_OUT
;
3433 adsl_ppe_intf
= *RETX_ADSL_PPE_INTF
;
3435 memcpy(&dtu_vld_stat
, (void *)DTU_VLD_STAT
, sizeof(dtu_vld_stat
));
3436 memcpy(&dtu_stat_info
, (void *)DTU_STAT_INFO
, sizeof(dtu_stat_info
));
3439 llen
+= sprintf(str
+ llen
, "Adsl-PPE Interface:\n");
3440 llen
+= sprintf(str
+ llen
, " dtu_sid = 0x%02x [%3u]\n", adsl_ppe_intf
.dtu_sid
, adsl_ppe_intf
.dtu_sid
);
3441 llen
+= sprintf(str
+ llen
, " dtu_timestamp = 0x%02x\n", adsl_ppe_intf
.dtu_timestamp
);
3442 llen
+= sprintf(str
+ llen
, " local_time = 0x%02x\n", adsl_ppe_intf
.local_time
);
3443 llen
+= sprintf(str
+ llen
, " is_last_cw = %u\n", adsl_ppe_intf
.is_last_cw
);
3444 llen
+= sprintf(str
+ llen
, " reinit_flag = %u\n", adsl_ppe_intf
.reinit_flag
);
3445 llen
+= sprintf(str
+ llen
, " is_bad_cw = %u\n", adsl_ppe_intf
.is_bad_cw
);
3446 llen
+= sprintf(str
+ llen
, "\n");
3448 llen
+= sprintf(str
+ llen
, "Retx Internal State:\n");
3449 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
);
3450 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
);
3451 llen
+= sprintf(str
+ llen
, " next_cell_sid_out (0x%08x) = %u\n", (unsigned int )NEXT_CELL_SID_OUT
, next_cell_sid_out
);
3452 llen
+= sprintf(str
+ llen
, " dtu_valid_stat (0x%08x)\n", (unsigned int )DTU_VLD_STAT
);
3453 llen
+= sprintf(str
+ llen
, " dtu_stat_info (0x%08x)\n", (unsigned int )DTU_STAT_INFO
);
3454 llen
+= sprintf(str
+ llen
, " pb_buffer_usage (0x%08x)\n", (unsigned int )PB_BUFFER_USAGE
);
3456 if ( len
<= off
&& len
+ llen
> off
) {
3457 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3458 pstr
+= len
+ llen
- off
;
3460 else if ( len
> off
) {
3461 memcpy(pstr
, str
, llen
);
3465 if ( len
>= len_max
)
3466 goto PROC_READ_RETX_STATS_OVERRUN_END
;
3470 llen
+= sprintf(str
+ llen
, "\n");
3471 llen
+= sprintf(str
+ llen
, "DTU_VALID_STAT: [0x%08x]:\n", (unsigned int)DTU_VLD_STAT
);
3472 llen
+= sprintf(str
+ llen
, "%08X: %08X %08X %08X %08X %08X %08X %08X %08X\n",
3473 (unsigned int)DTU_VLD_STAT
,
3474 dtu_vld_stat
[0], dtu_vld_stat
[1], dtu_vld_stat
[2], dtu_vld_stat
[3],
3475 dtu_vld_stat
[4], dtu_vld_stat
[5], dtu_vld_stat
[6], dtu_vld_stat
[7]);
3477 if ( len
<= off
&& len
+ llen
> off
) {
3478 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3479 pstr
+= len
+ llen
- off
;
3481 else if ( len
> off
) {
3482 memcpy(pstr
, str
, llen
);
3486 if ( len
>= len_max
)
3487 goto PROC_READ_RETX_STATS_OVERRUN_END
;
3491 llen
+= sprintf(str
+ llen
, "\n");
3492 llen
+= sprintf(str
+ llen
, "DTU_STAT_INFO: [0x%08x]:\n", (unsigned int)DTU_STAT_INFO
);
3493 llen
+= sprintf(str
+ llen
, "dtu_id ts complete bad cell_cnt dtu_rd_ptr dtu_wr_ptr\n");
3494 llen
+= sprintf(str
+ llen
, "---------------------------------------------------------------------\n");
3495 for ( i
= 0; i
< 256; i
++ ) {
3496 if ( !is_valid(dtu_vld_stat
, i
) )
3499 llen
+= sprintf(str
+ llen
, "0x%02x [%3u] 0x%02x %d %d %3d %5d %5d\n",
3501 DTU_STAT_INFO
[i
].time_stamp
,
3502 DTU_STAT_INFO
[i
].complete
,
3503 DTU_STAT_INFO
[i
].bad
,
3504 DTU_STAT_INFO
[i
].cell_cnt
,
3505 DTU_STAT_INFO
[i
].dtu_rd_ptr
,
3506 DTU_STAT_INFO
[i
].dtu_wr_ptr
);
3508 if ( len
<= off
&& len
+ llen
> off
) {
3509 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3510 pstr
+= len
+ llen
- off
;
3512 else if ( len
> off
)
3514 memcpy(pstr
, str
, llen
);
3518 if ( len
>= len_max
)
3519 goto PROC_READ_RETX_STATS_OVERRUN_END
;
3524 llen
+= sprintf(str
+ llen
, "\n");
3525 llen
+= sprintf(str
+ llen
, "Playout buffer status --- valid status [0x%08x]:\n", (unsigned int)PB_BUFFER_USAGE
);
3526 for( i
= 0; i
< RETX_MODE_CFG
->buff_size
; i
+= 8 ) {
3527 llen
+= sprintf(str
+ llen
, "%08X: %08X %08X %08X %08X %08X %08X %08X %08X\n",
3528 (unsigned int)PB_BUFFER_USAGE
+ i
* sizeof(unsigned int),
3529 PB_BUFFER_USAGE
[i
], PB_BUFFER_USAGE
[i
+1], PB_BUFFER_USAGE
[i
+2], PB_BUFFER_USAGE
[i
+3],
3530 PB_BUFFER_USAGE
[i
+4], PB_BUFFER_USAGE
[i
+5], PB_BUFFER_USAGE
[i
+6], PB_BUFFER_USAGE
[i
+7]);
3533 if ( len
<= off
&& len
+ llen
> off
) {
3534 memcpy(pstr
, str
+ off
- len
, len
+ llen
- off
);
3535 pstr
+= len
+ llen
- off
;
3537 else if ( len
> off
) {
3538 memcpy(pstr
, str
, llen
);
3542 if ( len
>= len_max
)
3543 goto PROC_READ_RETX_STATS_OVERRUN_END
;
3551 PROC_READ_RETX_STATS_OVERRUN_END
:
3552 return len
- llen
- off
;
3555 static int proc_write_retx_stats(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
3562 len
= count
< sizeof(str
) ? count
: sizeof(str
) - 1;
3563 rlen
= len
- copy_from_user(str
, buf
, len
);
3564 while ( rlen
&& str
[rlen
- 1] <= ' ' )
3567 for ( p
= str
; *p
&& *p
<= ' '; p
++, rlen
-- );
3571 if ( stricmp(p
, "help") == 0 ) {
3572 printk("echo clear_pb > /proc/driver/ifx_atm/retx_stats \n");
3573 printk(" :clear context in playout buffer\n\n");
3574 printk("echo read_pb <pb_index> <cell_num> > /proc/driver/ifx_atm/retx_stats\n");
3575 printk(" : read playout buffer contents\n\n");
3576 printk("echo read_[r|t]x_cb > /proc/driver/ifx_atm/retx_stats\n");
3577 printk(" : read cell buffer\n\n");
3578 printk("echo clear_[r|t]x_cb > /proc/driver/ifx_atm/retx_stats\n");
3579 printk(" : clear cell buffer\n\n");
3580 printk("echo read_bad_dtu_intf_rec > /proc/driver/ifx_atm/retx_stats\n");
3581 printk(" : read bad dtu intrface information record\n\n");
3582 printk("echo clear_bad_dtu_intf_rec > /proc/driver/ifx_atm/retx_stats\n");
3583 printk(" : clear bad dtu interface information record\n\n");
3584 printk("echo read_wrx_context [i] > /proc/driver/ifx_atm/retx_stats\n");
3585 printk(" : clear bad dtu interface information record\n\n");
3586 printk("echo read_intf_rec > /proc/driver/ifx_atm/retx_stats\n");
3587 printk(" : read interface info record buffer\n\n");
3588 printk("echo reinit_intf_rec > /proc/driver/ifx_atm/retx_stats\n");
3589 printk(" : reinit intf record, must be called before showtime\n\n");
3591 else if ( stricmp(p
, "reinit_intf_rec") == 0 ) {
3593 struct Retx_adsl_ppe_intf_rec rec
[16];
3595 *DBG_DTU_INTF_WRPTR
= 0;
3596 *DBG_INTF_FCW_DUP_CNT
= 0;
3597 *DBG_INTF_SID_CHANGE_IN_DTU_CNT
= 0;
3598 *DBG_INTF_LCW_DUP_CNT
= 0;
3600 *DBG_RFBI_DONE_INT_CNT
= 0;
3601 *DBG_RFBI_INTV0
= 0;
3602 *DBG_RFBI_INTV1
= 0;
3603 *DBG_RFBI_BC0_INVALID_CNT
= 0;
3604 *DBG_RFBI_LAST_T
= 0;
3605 *DBG_DREG_BEG_END
= 0;
3607 memset((void *) DBG_INTF_INFO(0), 0, sizeof(rec
));
3608 for( i
= 0; i
< 16; i
++ )
3609 DBG_INTF_INFO(i
)->res1_1
= 1;
3610 DBG_INTF_INFO(15)->dtu_sid
= 255;
3612 else if ( stricmp(p
, "read_intf_rec") == 0 ) {
3614 unsigned int dtu_intf_wrptr
, fcw_dup_cnt
, sid_change_in_dtu_cnt
, lcw_dup_cnt
;
3615 unsigned int rfbi_done_int_cnt
, rfbi_intv0
, rfbi_intv1
, rfbi_bc0_invalid_cnt
, dreg_beg_end
;
3616 struct Retx_adsl_ppe_intf_rec rec
[16];
3618 memcpy((void *) rec
, (void *) DBG_INTF_INFO(0), sizeof(rec
));
3620 dtu_intf_wrptr
= *DBG_DTU_INTF_WRPTR
;
3621 fcw_dup_cnt
= *DBG_INTF_FCW_DUP_CNT
;
3622 sid_change_in_dtu_cnt
= *DBG_INTF_SID_CHANGE_IN_DTU_CNT
;
3623 lcw_dup_cnt
= *DBG_INTF_LCW_DUP_CNT
;
3625 rfbi_done_int_cnt
= *DBG_RFBI_DONE_INT_CNT
;
3626 rfbi_intv0
= *DBG_RFBI_INTV0
;
3627 rfbi_intv1
= *DBG_RFBI_INTV1
;
3628 rfbi_bc0_invalid_cnt
= *DBG_RFBI_BC0_INVALID_CNT
;
3629 dreg_beg_end
= *DBG_DREG_BEG_END
;
3631 printk("PPE-Adsl Interface recrod [addr 0x23F0]:\n\n");
3633 printk(" rfbi_done_int_cnt = %d [0x%x] \n", rfbi_done_int_cnt
, rfbi_done_int_cnt
);
3634 printk(" rfbi_intv = 0x%08x 0x%08x [%d, %d, %d, %d, %d, %d, %d, %d]\n",
3635 rfbi_intv0
, rfbi_intv1
,
3636 rfbi_intv0
>> 24, (rfbi_intv0
>>16) & 0xff, (rfbi_intv0
>>8) & 0xff, rfbi_intv0
& 0xff,
3637 rfbi_intv1
>> 24, (rfbi_intv1
>>16) & 0xff, (rfbi_intv1
>>8) & 0xff, rfbi_intv1
& 0xff
3639 printk(" rfbi_bc0_invld_cnt = %d\n", rfbi_bc0_invalid_cnt
);
3640 printk(" dreg_beg_end = %d, %d\n\n", dreg_beg_end
>> 16, dreg_beg_end
& 0xffff);
3642 printk(" wrptr = %d [0x%x] \n", dtu_intf_wrptr
, dtu_intf_wrptr
);
3643 printk(" fcw_dup_cnt = %d\n", fcw_dup_cnt
);
3644 printk(" sid_chg_cnt = %d\n", sid_change_in_dtu_cnt
);
3645 printk(" lcw_dup_cnt = %d\n\n", lcw_dup_cnt
);
3648 printk(" idx itf_dw0 itf_dw1 dtu_sid timestamp local_time res1 last_cw bad_flag reinit\n");
3649 printk(" -------------------------------------------------------------------------------------\n");
3650 for ( i
= (dtu_intf_wrptr
+ 1) % 16, cnt
= 0; cnt
< 16; cnt
++, i
= (i
+ 1) % 16 ) {
3655 printk("%3d %04x %04x %3d[%02x] %3d[%02x] %3d[%02x] 0x%02x %d %d %d\n",
3657 (*(unsigned int *)&rec
[i
]) & 0xffff,
3658 (*(unsigned int *)&rec
[i
]) >> 16,
3659 rec
[i
].dtu_sid
, rec
[i
].dtu_sid
,
3660 rec
[i
].dtu_timestamp
, rec
[i
].dtu_timestamp
,
3661 rec
[i
].local_time
, rec
[i
].local_time
,
3665 rec
[i
].reinit_flag
);
3668 else if ( stricmp(p
, "read_wrx_context") == 0 ) {
3671 for( i
= 0; i
< 8; ++i
) {
3672 if ( !WRX_QUEUE_CONTEXT(i
)->curr_des0
|| !WRX_QUEUE_CONTEXT(i
)->curr_des1
)
3676 printk("WRX queue context [ %d ]: \n", i
);
3677 printk(" curr_len = %4d, mfs = %d, ec = %d, clp1 = %d, aal5dp = %d\n",
3678 WRX_QUEUE_CONTEXT(i
)->curr_len
, WRX_QUEUE_CONTEXT(i
)->mfs
,
3679 WRX_QUEUE_CONTEXT(i
)->ec
, WRX_QUEUE_CONTEXT(i
)->clp1
,
3680 WRX_QUEUE_CONTEXT(i
)->aal5dp
);
3681 printk(" initcrc = %08x\n", WRX_QUEUE_CONTEXT(i
)->intcrc
);
3682 printk(" currdes = %08x %08x\n",
3683 WRX_QUEUE_CONTEXT(i
)->curr_des0
, WRX_QUEUE_CONTEXT(i
)->curr_des1
);
3684 printk(" last_dw = %08x\n\n", WRX_QUEUE_CONTEXT(i
)->last_dword
);
3685 if( WRX_QUEUE_CONTEXT(i
)->curr_len
) {
3687 unsigned char *p_char
;
3688 struct rx_descriptor
*desc
= (struct rx_descriptor
*)&(WRX_QUEUE_CONTEXT(i
)->curr_des0
);
3689 p_char
= (unsigned char *)(((unsigned int)desc
->dataptr
<< 2) | KSEG1
);
3690 printk(" Data in SDRAM:\n ");
3692 for ( j
= 0 ; j
< WRX_QUEUE_CONTEXT(i
)->curr_len
; ++j
) {
3693 printk ("%02x", p_char
[j
]);
3696 else if ( j
% 4 == 3 )
3703 printk("No active wrx queue context\n");
3706 else if ( stricmp(p
, "clear_pb") == 0 ) {
3707 if ( g_retx_playout_buffer
)
3708 memset((void *)g_retx_playout_buffer
, 0, RETX_PLAYOUT_BUFFER_SIZE
);
3710 else if ( stricmp(p
, "read_bad_dtu_intf_rec") == 0 ) {
3711 struct Retx_adsl_ppe_intf first_dtu_intf
, last_dtu_intf
;
3712 first_dtu_intf
= *FIRST_BAD_REC_RETX_ADSL_PPE_INTF
;
3713 last_dtu_intf
= *BAD_REC_RETX_ADSL_PPE_INTF
;
3715 printk("\nAdsl-PPE Interface for first and last DTU of recent noise:\n\n");
3716 printk(" dtu_sid = 0x%02x [%3u], 0x%02x [%3u]\n",
3717 first_dtu_intf
.dtu_sid
, first_dtu_intf
.dtu_sid
,
3718 last_dtu_intf
.dtu_sid
, last_dtu_intf
.dtu_sid
);
3719 printk(" dtu_timestamp = 0x%02x , 0x%02x\n",
3720 first_dtu_intf
.dtu_timestamp
, last_dtu_intf
.dtu_timestamp
);
3721 printk(" local_time = 0x%02x , 0x%02x\n",
3722 first_dtu_intf
.local_time
, last_dtu_intf
.local_time
);
3723 printk(" is_last_cw = %u , %u\n",
3724 first_dtu_intf
.is_last_cw
, last_dtu_intf
.is_last_cw
);
3725 printk(" reinit_flag = %u , %u\n",
3726 first_dtu_intf
.reinit_flag
, last_dtu_intf
.reinit_flag
);
3727 printk(" is_bad_cw = %u , %u\n\n",
3728 first_dtu_intf
.is_bad_cw
, last_dtu_intf
.is_bad_cw
);
3730 else if ( stricmp(p
, "clear_bad_dtu_intf_rec") == 0 ) {
3731 memset((void *)BAD_REC_RETX_ADSL_PPE_INTF
, 0, sizeof(struct Retx_adsl_ppe_intf
));
3732 memset((void *)FIRST_BAD_REC_RETX_ADSL_PPE_INTF
, 0, sizeof(struct Retx_adsl_ppe_intf
));
3734 else if ( stricmp(p
, "clear_tx_cb") == 0 ) {
3735 unsigned int *dbase0
;
3738 dbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( FFSM_DBA(0)->dbase
+ 0x2000);
3739 pnum0
= FFSM_CFG(0)->pnum
;
3740 memset(dbase0
, 0, 14 * sizeof(unsigned int ) * pnum0
);
3742 else if ( stricmp(p
, "clear_rx_cb") == 0 ) {
3743 unsigned int *dbase0
, *cbase0
, *dbase1
, *cbase1
;
3746 dbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_DBA(0)->dbase
+ 0x2000);
3747 cbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_CBA(0)->cbase
+ 0x2000);
3749 dbase1
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_DBA(1)->dbase
+ 0x2000);
3750 cbase1
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_CBA(1)->cbase
+ 0x2000);
3752 pnum0
= SFSM_CFG(0)->pnum
;
3754 memset(dbase0
, 0, 14 * sizeof(unsigned int ) * pnum0
);
3755 memset(cbase0
, 0, sizeof(unsigned int ) * pnum0
);
3757 memset(dbase1
, 0, 14 * sizeof(unsigned int ));
3758 memset(cbase1
, 0, sizeof(unsigned int ));
3760 else if ( strnicmp(p
, "read_tx_cb", 10) == 0 ) {
3761 unsigned int *dbase0
;
3762 unsigned int pnum0
, i
;
3763 unsigned int * cell
;
3765 dbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( FFSM_DBA(0)->dbase
+ 0x2000);
3766 pnum0
= FFSM_CFG(0)->pnum
;
3768 printk("ATM TX BC 0 CELL data/ctrl buffer:\n\n");
3769 for(i
= 0; i
< pnum0
; ++ i
) {
3770 cell
= dbase0
+ i
* 14;
3771 printk("cell %2d: %08x %08x\n", i
, cell
[0], cell
[1]);
3772 printk(" %08x %08x %08x %08x\n", cell
[2], cell
[3], cell
[4], cell
[5]);
3773 printk(" %08x %08x %08x %08x\n", cell
[6], cell
[7], cell
[8], cell
[9]);
3774 printk(" %08x %08x %08x %08x\n", cell
[10], cell
[11], cell
[12], cell
[13]);
3777 else if ( strnicmp(p
, "read_rx_cb", 10) == 0 ) {
3778 unsigned int *dbase0
, *cbase0
, *dbase1
, *cbase1
;
3779 unsigned int pnum0
, i
;
3780 unsigned int * cell
;
3782 dbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_DBA(0)->dbase
+ 0x2000);
3783 cbase0
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_CBA(0)->cbase
+ 0x2000);
3785 dbase1
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_DBA(1)->dbase
+ 0x2000);
3786 cbase1
= (unsigned int *)PPM_INT_UNIT_ADDR( SFSM_CBA(1)->cbase
+ 0x2000);
3788 pnum0
= SFSM_CFG(0)->pnum
;
3790 printk("ATM RX BC 0 CELL data/ctrl buffer:\n\n");
3791 for(i
= 0; i
< pnum0
; ++ i
) {
3792 struct Retx_ctrl_field
* p_ctrl
;
3794 cell
= dbase0
+ i
* 14;
3795 p_ctrl
= (struct Retx_ctrl_field
*) ( &cbase0
[i
]);
3796 printk("cell %2d: %08x %08x -- [%08x]:", i
, cell
[0], cell
[1], cbase0
[i
]);
3798 printk("l2_drop: %d, retx: %d", p_ctrl
->l2_drop
, p_ctrl
->retx
);
3799 if ( p_ctrl
->retx
) {
3800 printk(", dtu_sid = %u, cell_sid = %u", p_ctrl
->dtu_sid
, p_ctrl
->cell_sid
);
3805 printk(" %08x %08x %08x %08x\n", cell
[2], cell
[3], cell
[4], cell
[5]);
3806 printk(" %08x %08x %08x %08x\n", cell
[6], cell
[7], cell
[8], cell
[9]);
3807 printk(" %08x %08x %08x %08x\n", cell
[10], cell
[11], cell
[12], cell
[13]);
3811 printk("ATM RX BC 1 CELL data/ctrl buffer:\n\n");
3813 printk("cell %2d: %08x %08x -- [%08x]: dtu_sid:%3d, cell_sid:%3d, next_ptr: %4d\n",
3814 0, cell
[0], cell
[1], cbase0
[i
], ( cell
[1] >> 16) & 0xff, (cell
[1] >> 24) & 0xff, cell
[1] & 0xffff );
3815 printk(" %08x %08x %08x %08x\n", cell
[2], cell
[3], cell
[4], cell
[5]);
3816 printk(" %08x %08x %08x %08x\n", cell
[6], cell
[7], cell
[8], cell
[9]);
3817 printk(" %08x %08x %08x %08x\n", cell
[10], cell
[11], cell
[12], cell
[13]);
3819 else if ( strnicmp(p
, "read_pb ", 8) == 0 )
3821 int start_cell_idx
= 0;
3824 unsigned int pb_buff_size
= RETX_MODE_CFG
->buff_size
* 32;
3828 ignore_space(&p
, &rlen
);
3830 start_cell_idx
= get_number(&p
, &rlen
, 0);
3831 ignore_space(&p
, &rlen
);
3832 cell_num
= get_number(&p
, &rlen
, 0);
3834 if ( start_cell_idx
>= pb_buff_size
) {
3835 printk(" Invalid cell index\n");
3842 if ( cell_num
+ start_cell_idx
> pb_buff_size
)
3843 cell_num
= pb_buff_size
- start_cell_idx
;
3845 for ( i
= 0; i
< cell_num
; ++i
) {
3846 cell
= (unsigned int *)((unsigned int *)g_retx_playout_buffer
+ (14 * (start_cell_idx
+ i
)));
3847 printk("cell %4d: %08x %08x [next_ptr = %4u, dtu_sid = %3u, cell_sid = %3u]\n",
3848 start_cell_idx
+ i
, cell
[0], cell
[1], cell
[1] & 0xffff, (cell
[1] >> 16) & 0xff, (cell
[1] >> 24) & 0xff);
3849 printk(" %08x %08x %08x %08x\n", cell
[2], cell
[3], cell
[4], cell
[5]);
3850 printk(" %08x %08x %08x %08x\n", cell
[6], cell
[7], cell
[8], cell
[9]);
3851 printk(" %08x %08x %08x %08x\n", cell
[10], cell
[11], cell
[12], cell
[13]);
3859 static int proc_read_retx_cfg(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3863 len
+= sprintf(page
+ off
+ len
, "ReTX FW Config:\n");
3864 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
);
3865 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
);
3866 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
);
3867 len
+= sprintf(page
+ off
+ len
, " RETX_PLAYOUT_BUFFER_BASE = 0x%08x\n", *RETX_PLAYOUT_BUFFER_BASE
);
3868 len
+= sprintf(page
+ off
+ len
, " RETX_SERVICE_HEADER_CFG = 0x%08x\n", *RETX_SERVICE_HEADER_CFG
);
3869 len
+= sprintf(page
+ off
+ len
, " RETX_MASK_HEADER_CFG = 0x%08x\n", *RETX_MASK_HEADER_CFG
);
3870 len
+= sprintf(page
+ off
+ len
, " RETX_MIB_TIMER_CFG = 0x%08x, tick_cycle = %d, ticks_per_sec = %d\n",
3871 *(unsigned int *)RETX_MIB_TIMER_CFG
, RETX_MIB_TIMER_CFG
->tick_cycle
, RETX_MIB_TIMER_CFG
->ticks_per_sec
);
3878 static int proc_write_retx_cfg(struct file
*file
, const char *buf
, unsigned long count
, void *data
)
3883 char local_buf
[1024];
3884 char *tokens
[4] = {0};
3885 unsigned int token_num
= 0;
3887 len
= sizeof(local_buf
) < count
? sizeof(local_buf
) - 1 : count
;
3888 len
= len
- copy_from_user(local_buf
, buf
, len
);
3893 while ( token_num
< NUM_ENTITY(tokens
) && get_token(&p1
, &p2
, &len
, &colon
) ) {
3894 tokens
[token_num
++] = p1
;
3899 if ( token_num
> 0 ) {
3900 if ( stricmp(tokens
[0], "help") == 0 ) {
3901 printk("echo help > /proc/driver/ifx_atm/retx_cfg ==> \n\tprint this help message\n\n");
3903 printk("echo set retx <enable|disable|0|1|on|off> > /proc/driver/ifx_atm/retx_cfg\n");
3904 printk("\t:enable or disable retx feature\n\n");
3906 printk("echo set <td_max|td_min|fw_alpha|sync_inp|invld_range|buff_size> <number> > /proc/driver/ifx_atm/retx_cfg\n");
3907 printk("\t: set td_max, td_min, fw_alpha, sync_inp, invalid_range, buff_size\n\n");
3909 printk("echo set <service_header|service_mask> <hex_number> /proc/driver/ifx_atm/retx_cfg \n");
3910 printk("\t: set service_header, service_mask\n\n");
3912 else if ( stricmp(tokens
[0], "set") == 0 && token_num
>= 3 ) {
3914 if ( stricmp(tokens
[1], "retx") == 0 ) {
3915 if ( stricmp(tokens
[2], "enable") == 0 ||
3916 stricmp(tokens
[2], "on") == 0 ||
3917 stricmp(tokens
[2], "1") == 0 )
3918 RETX_MODE_CFG
->retx_en
= 1;
3919 else if ( stricmp(tokens
[2], "disable") == 0 ||
3920 stricmp(tokens
[2], "off") == 0 ||
3921 stricmp(tokens
[2], "0") == 0 )
3922 RETX_MODE_CFG
->retx_en
= 0;
3923 printk("RETX_MODE_CFG->retx_en - %d\n", RETX_MODE_CFG
->retx_en
);
3926 unsigned int dec_val
, hex_val
;
3929 dec_val
= (unsigned int)get_number(&p1
, NULL
, 0);
3931 hex_val
= (unsigned int)get_number(&p2
, NULL
, 1);
3934 if ( stricmp(tokens
[1], "service_header") == 0 ) {
3935 *RETX_SERVICE_HEADER_CFG
= hex_val
;
3936 printk("RETX_SERVICE_HEADER_CFG - 0x%08x\n", *RETX_SERVICE_HEADER_CFG
);
3938 else if ( stricmp(tokens
[1], "service_mask") == 0 ) {
3939 *RETX_MASK_HEADER_CFG
= hex_val
;
3940 printk("RETX_MASK_HEADER_CFG - 0x%08x\n", *RETX_MASK_HEADER_CFG
);
3944 if ( stricmp(tokens
[1], "td_max") == 0 ) {
3945 (unsigned int)RETX_TD_CFG
->td_max
= (dec_val
>= 0xff ? 0Xff : dec_val
);
3946 printk("RETX_TD_CFG->td_max - %d\n", RETX_TD_CFG
->td_max
);
3948 else if ( stricmp(tokens
[1], "td_min") == 0 ) {
3949 (unsigned int)RETX_TD_CFG
->td_min
= (dec_val
>= 0xff ? 0Xff : dec_val
);
3950 printk("RETX_TD_CFG->td_min - %d\n", RETX_TD_CFG
->td_min
);
3952 else if ( stricmp(tokens
[1], "fw_alpha") == 0 ) {
3953 RETX_TSYNC_CFG
->fw_alpha
= dec_val
>= 0x7FFE ? 0X7EEE : dec_val
;
3954 printk("RETX_TSYNC_CFG->fw_alpha - %d\n", RETX_TSYNC_CFG
->fw_alpha
);
3956 else if ( stricmp(tokens
[1], "sync_inp") == 0 ) {
3957 RETX_TSYNC_CFG
->sync_inp
= dec_val
>= 0x7FFE ? 0X7EEE : dec_val
;
3958 printk("RETX_TSYNC_CFG->sync_inp - %d\n", RETX_TSYNC_CFG
->sync_inp
);
3960 else if ( stricmp(tokens
[1], "invld_range") == 0 ) {
3961 RETX_MODE_CFG
->invld_range
= dec_val
>= 250 ? 250 : dec_val
;
3962 printk("RETX_MODE_CFG->invld_range - %d\n", RETX_MODE_CFG
->invld_range
);
3964 else if ( stricmp(tokens
[1], "buff_size") == 0 ) {
3965 dec_val
= (dec_val
+ 31) / 32;
3966 RETX_MODE_CFG
->buff_size
= dec_val
>= 4096 / 32 ? 4096 / 32 : dec_val
;
3967 printk("RETX_MODE_CFG->buff_size - %d\n", RETX_MODE_CFG
->buff_size
);
3978 static int proc_read_retx_dsl_param(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
3982 len
+= sprintf(page
+ off
+ len
, "DSL Param [timestamp %ld.%ld]:\n", g_retx_polling_start
.tv_sec
, g_retx_polling_start
.tv_usec
);
3984 if ( g_xdata_addr
== NULL
)
3985 len
+= sprintf(page
+ off
+ len
, " DSL parameters not available !\n");
3987 volatile struct dsl_param
*p_dsl_param
= (volatile struct dsl_param
*)g_xdata_addr
;
3989 len
+= sprintf(page
+ off
+ len
, " update_flag = %u\n", p_dsl_param
->update_flag
);
3990 len
+= sprintf(page
+ off
+ len
, " MinDelayrt = %u\n", p_dsl_param
->MinDelayrt
);
3991 len
+= sprintf(page
+ off
+ len
, " MaxDelayrt = %u\n", p_dsl_param
->MaxDelayrt
);
3992 len
+= sprintf(page
+ off
+ len
, " RetxEnable = %u\n", p_dsl_param
->RetxEnable
);
3993 len
+= sprintf(page
+ off
+ len
, " ServiceSpecificReTx = %u\n", p_dsl_param
->ServiceSpecificReTx
);
3994 len
+= sprintf(page
+ off
+ len
, " ReTxPVC = 0x%08x\n", p_dsl_param
->ReTxPVC
);
3995 len
+= sprintf(page
+ off
+ len
, " RxDtuCorruptedCNT = %u\n", p_dsl_param
->RxDtuCorruptedCNT
);
3996 len
+= sprintf(page
+ off
+ len
, " RxRetxDtuUnCorrectedCNT = %u\n", p_dsl_param
->RxRetxDtuUnCorrectedCNT
);
3997 len
+= sprintf(page
+ off
+ len
, " RxLastEFB = %u\n", p_dsl_param
->RxLastEFB
);
3998 len
+= sprintf(page
+ off
+ len
, " RxDtuCorrectedCNT = %u\n", p_dsl_param
->RxDtuCorrectedCNT
);
4000 if ( g_retx_polling_end
.tv_sec
!= 0 || g_retx_polling_end
.tv_usec
!= 0 ) {
4001 unsigned long polling_time_usec
;
4003 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
);
4004 len
+= sprintf(page
+ off
+ len
, "DSL Param Update Time: %lu.%03lums\n", polling_time_usec
/ 1000, polling_time_usec
% 1000);
4014 static int stricmp(const char *p1
, const char *p2
)
4018 while ( *p1
&& *p2
) {
4019 c1
= *p1
>= 'A' && *p1
<= 'Z' ? *p1
+ 'a' - 'A' : *p1
;
4020 c2
= *p2
>= 'A' && *p2
<= 'Z' ? *p2
+ 'a' - 'A' : *p2
;
4030 #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
4032 static int strincmp(const char *p1
, const char *p2
, int n
)
4036 while ( n
&& *p1
&& *p2
) {
4037 c1
= *p1
>= 'A' && *p1
<= 'Z' ? *p1
+ 'a' - 'A' : *p1
;
4038 c2
= *p2
>= 'A' && *p2
<= 'Z' ? *p2
+ 'a' - 'A' : *p2
;
4046 return n
? *p1
- *p2
: c1
;
4049 static int get_token(char **p1
, char **p2
, int *len
, int *colon
)
4053 while ( *len
&& !((**p1
>= 'A' && **p1
<= 'Z') || (**p1
>= 'a' && **p1
<= 'z') || (**p1
>= '0' && **p1
<= '9')) )
4065 while ( *len
&& **p2
> ' ' && **p2
!= ',' )
4081 while ( *len
&& **p2
> ' ' && **p2
!= ',' )
4093 static unsigned int get_number(char **p
, int *len
, int is_hex
)
4095 unsigned int ret
= 0;
4098 if ( (*p
)[0] == '0' && (*p
)[1] == 'x' )
4108 while ( (!len
|| *len
) && ((**p
>= '0' && **p
<= '9') || (**p
>= 'a' && **p
<= 'f') || (**p
>= 'A' && **p
<= 'F')) )
4110 if ( **p
>= '0' && **p
<= '9' )
4112 else if ( **p
>= 'a' && **p
<= 'f' )
4114 else if ( **p
>= 'A' && **p
<= 'F' )
4116 ret
= (ret
<< 4) | n
;
4124 while ( (!len
|| *len
) && **p
>= '0' && **p
<= '9' )
4137 static void ignore_space(char **p
, int *len
)
4139 while ( *len
&& (**p
<= ' ' || **p
== ':' || **p
== '.' || **p
== ',') )
4148 static INLINE
int ifx_atm_version(char *buf
)
4151 unsigned int major
, minor
;
4153 ifx_atm_get_fw_ver(&major
, &minor
);
4155 len
+= sprintf(buf
+ len
, " ATM (A1) firmware version %d.%d.%d\n", IFX_ATM_VER_MAJOR
, IFX_ATM_VER_MID
,IFX_ATM_VER_MINOR
);
4160 static INLINE
void check_parameters(void)
4162 /* Please refer to Amazon spec 15.4 for setting these values. */
4165 if ( qsb_tstep
< 1 )
4167 else if ( qsb_tstep
> 4 )
4169 else if ( qsb_tstep
== 3 )
4172 /* There is a delay between PPE write descriptor and descriptor is */
4173 /* really stored in memory. Host also has this delay when writing */
4174 /* descriptor. So PPE will use this value to determine if the write */
4175 /* operation makes effect. */
4176 if ( write_descriptor_delay
< 0 )
4177 write_descriptor_delay
= 0;
4179 if ( aal5_fill_pattern
< 0 )
4180 aal5_fill_pattern
= 0;
4182 aal5_fill_pattern
&= 0xFF;
4184 /* Because of the limitation of length field in descriptors, the packet */
4185 /* size could not be larger than 64K minus overhead size. */
4186 if ( aal5r_max_packet_size
< 0 )
4187 aal5r_max_packet_size
= 0;
4188 else if ( aal5r_max_packet_size
>= 65535 - MAX_RX_FRAME_EXTRA_BYTES
)
4189 aal5r_max_packet_size
= 65535 - MAX_RX_FRAME_EXTRA_BYTES
;
4190 if ( aal5r_min_packet_size
< 0 )
4191 aal5r_min_packet_size
= 0;
4192 else if ( aal5r_min_packet_size
> aal5r_max_packet_size
)
4193 aal5r_min_packet_size
= aal5r_max_packet_size
;
4194 if ( aal5s_max_packet_size
< 0 )
4195 aal5s_max_packet_size
= 0;
4196 else if ( aal5s_max_packet_size
>= 65535 - MAX_TX_FRAME_EXTRA_BYTES
)
4197 aal5s_max_packet_size
= 65535 - MAX_TX_FRAME_EXTRA_BYTES
;
4198 if ( aal5s_min_packet_size
< 0 )
4199 aal5s_min_packet_size
= 0;
4200 else if ( aal5s_min_packet_size
> aal5s_max_packet_size
)
4201 aal5s_min_packet_size
= aal5s_max_packet_size
;
4203 if ( dma_rx_descriptor_length
< 2 )
4204 dma_rx_descriptor_length
= 2;
4205 if ( dma_tx_descriptor_length
< 2 )
4206 dma_tx_descriptor_length
= 2;
4207 if ( dma_rx_clp1_descriptor_threshold
< 0 )
4208 dma_rx_clp1_descriptor_threshold
= 0;
4209 else if ( dma_rx_clp1_descriptor_threshold
> dma_rx_descriptor_length
)
4210 dma_rx_clp1_descriptor_threshold
= dma_rx_descriptor_length
;
4212 if ( dma_tx_descriptor_length
< 2 )
4213 dma_tx_descriptor_length
= 2;
4216 static INLINE
int init_priv_data(void)
4220 struct rx_descriptor rx_desc
= {0};
4221 struct sk_buff
*skb
;
4222 volatile struct tx_descriptor
*p_tx_desc
;
4223 struct sk_buff
**ppskb
;
4225 // clear atm private data structure
4226 memset(&g_atm_priv_data
, 0, sizeof(g_atm_priv_data
));
4228 // allocate memory for RX (AAL) descriptors
4229 p
= kzalloc(dma_rx_descriptor_length
* sizeof(struct rx_descriptor
) + DESC_ALIGNMENT
, GFP_KERNEL
);
4232 dma_cache_wback_inv((unsigned long)p
, dma_rx_descriptor_length
* sizeof(struct rx_descriptor
) + DESC_ALIGNMENT
);
4233 g_atm_priv_data
.aal_desc_base
= p
;
4234 p
= (void *)((((unsigned int)p
+ DESC_ALIGNMENT
- 1) & ~(DESC_ALIGNMENT
- 1)) | KSEG1
);
4235 g_atm_priv_data
.aal_desc
= (volatile struct rx_descriptor
*)p
;
4237 // allocate memory for RX (OAM) descriptors
4238 p
= kzalloc(RX_DMA_CH_OAM_DESC_LEN
* sizeof(struct rx_descriptor
) + DESC_ALIGNMENT
, GFP_KERNEL
);
4241 dma_cache_wback_inv((unsigned long)p
, RX_DMA_CH_OAM_DESC_LEN
* sizeof(struct rx_descriptor
) + DESC_ALIGNMENT
);
4242 g_atm_priv_data
.oam_desc_base
= p
;
4243 p
= (void *)((((unsigned int)p
+ DESC_ALIGNMENT
- 1) & ~(DESC_ALIGNMENT
- 1)) | KSEG1
);
4244 g_atm_priv_data
.oam_desc
= (volatile struct rx_descriptor
*)p
;
4246 // allocate memory for RX (OAM) buffer
4247 p
= kzalloc(RX_DMA_CH_OAM_DESC_LEN
* RX_DMA_CH_OAM_BUF_SIZE
+ DATA_BUFFER_ALIGNMENT
, GFP_KERNEL
);
4250 dma_cache_wback_inv((unsigned long)p
, RX_DMA_CH_OAM_DESC_LEN
* RX_DMA_CH_OAM_BUF_SIZE
+ DATA_BUFFER_ALIGNMENT
);
4251 g_atm_priv_data
.oam_buf_base
= p
;
4252 p
= (void *)(((unsigned int)p
+ DATA_BUFFER_ALIGNMENT
- 1) & ~(DATA_BUFFER_ALIGNMENT
- 1));
4253 g_atm_priv_data
.oam_buf
= p
;
4255 // allocate memory for TX descriptors
4256 p
= kzalloc(MAX_PVC_NUMBER
* dma_tx_descriptor_length
* sizeof(struct tx_descriptor
) + DESC_ALIGNMENT
, GFP_KERNEL
);
4259 dma_cache_wback_inv((unsigned long)p
, MAX_PVC_NUMBER
* dma_tx_descriptor_length
* sizeof(struct tx_descriptor
) + DESC_ALIGNMENT
);
4260 g_atm_priv_data
.tx_desc_base
= p
;
4262 // allocate memory for TX skb pointers
4263 p
= kzalloc(MAX_PVC_NUMBER
* dma_tx_descriptor_length
* sizeof(struct sk_buff
*) + 4, GFP_KERNEL
);
4266 dma_cache_wback_inv((unsigned long)p
, MAX_PVC_NUMBER
* dma_tx_descriptor_length
* sizeof(struct sk_buff
*) + 4);
4267 g_atm_priv_data
.tx_skb_base
= p
;
4269 // setup RX (AAL) descriptors
4274 rx_desc
.byteoff
= 0;
4277 rx_desc
.datalen
= RX_DMA_CH_AAL_BUF_SIZE
;
4278 for ( i
= 0; i
< dma_rx_descriptor_length
; i
++ ) {
4279 skb
= alloc_skb_rx();
4282 rx_desc
.dataptr
= ((unsigned int)skb
->data
>> 2) & 0x0FFFFFFF;
4283 g_atm_priv_data
.aal_desc
[i
] = rx_desc
;
4286 // setup RX (OAM) descriptors
4287 p
= (void *)((unsigned int)g_atm_priv_data
.oam_buf
| KSEG1
);
4292 rx_desc
.byteoff
= 0;
4295 rx_desc
.datalen
= RX_DMA_CH_OAM_BUF_SIZE
;
4296 for ( i
= 0; i
< RX_DMA_CH_OAM_DESC_LEN
; i
++ ) {
4297 rx_desc
.dataptr
= ((unsigned int)p
>> 2) & 0x0FFFFFFF;
4298 g_atm_priv_data
.oam_desc
[i
] = rx_desc
;
4299 p
= (void *)((unsigned int)p
+ RX_DMA_CH_OAM_BUF_SIZE
);
4302 // setup TX descriptors and skb pointers
4303 p_tx_desc
= (volatile struct tx_descriptor
*)((((unsigned int)g_atm_priv_data
.tx_desc_base
+ DESC_ALIGNMENT
- 1) & ~(DESC_ALIGNMENT
- 1)) | KSEG1
);
4304 ppskb
= (struct sk_buff
**)(((unsigned int)g_atm_priv_data
.tx_skb_base
+ 3) & ~3);
4305 for ( i
= 0; i
< MAX_PVC_NUMBER
; i
++ ) {
4306 g_atm_priv_data
.conn
[i
].tx_desc
= &p_tx_desc
[i
* dma_tx_descriptor_length
];
4307 g_atm_priv_data
.conn
[i
].tx_skb
= &ppskb
[i
* dma_tx_descriptor_length
];
4310 for ( i
= 0; i
< ATM_PORT_NUMBER
; i
++ )
4311 g_atm_priv_data
.port
[i
].tx_max_cell_rate
= DEFAULT_TX_LINK_RATE
;
4316 static INLINE
void clear_priv_data(void)
4319 struct sk_buff
*skb
;
4321 for ( i
= 0; i
< MAX_PVC_NUMBER
; i
++ ) {
4322 if ( g_atm_priv_data
.conn
[i
].tx_skb
!= NULL
) {
4323 for ( j
= 0; j
< dma_tx_descriptor_length
; j
++ )
4324 if ( g_atm_priv_data
.conn
[i
].tx_skb
[j
] != NULL
)
4325 dev_kfree_skb_any(g_atm_priv_data
.conn
[i
].tx_skb
[j
]);
4329 if ( g_atm_priv_data
.tx_skb_base
!= NULL
)
4330 kfree(g_atm_priv_data
.tx_skb_base
);
4332 if ( g_atm_priv_data
.tx_desc_base
!= NULL
)
4333 kfree(g_atm_priv_data
.tx_desc_base
);
4335 if ( g_atm_priv_data
.oam_buf_base
!= NULL
)
4336 kfree(g_atm_priv_data
.oam_buf_base
);
4338 if ( g_atm_priv_data
.oam_desc_base
!= NULL
)
4339 kfree(g_atm_priv_data
.oam_desc_base
);
4341 if ( g_atm_priv_data
.aal_desc_base
!= NULL
) {
4342 for ( i
= 0; i
< dma_rx_descriptor_length
; i
++ ) {
4343 if ( g_atm_priv_data
.aal_desc
[i
].sop
|| g_atm_priv_data
.aal_desc
[i
].eop
) { // descriptor initialized
4344 skb
= get_skb_rx_pointer(g_atm_priv_data
.aal_desc
[i
].dataptr
);
4345 dev_kfree_skb_any(skb
);
4348 kfree(g_atm_priv_data
.aal_desc_base
);
4352 static INLINE
void init_rx_tables(void)
4355 struct wrx_queue_config wrx_queue_config
= {0};
4356 struct wrx_dma_channel_config wrx_dma_channel_config
= {0};
4357 struct htu_entry htu_entry
= {0};
4358 struct htu_result htu_result
= {0};
4359 struct htu_mask htu_mask
= { set
: 0x01,
4370 *CFG_WRX_HTUTS
= MAX_PVC_NUMBER
+ OAM_HTU_ENTRY_NUMBER
;
4371 #ifndef CONFIG_AMAZON_SE
4372 *CFG_WRX_QNUM
= MAX_QUEUE_NUMBER
;
4374 *CFG_WRX_DCHNUM
= RX_DMA_CH_TOTAL
;
4375 *WRX_DMACH_ON
= (1 << RX_DMA_CH_TOTAL
) - 1;
4376 *WRX_HUNT_BITTH
= DEFAULT_RX_HUNT_BITTH
;
4379 * WRX Queue Configuration Table
4381 wrx_queue_config
.uumask
= 0;
4382 wrx_queue_config
.cpimask
= 0;
4383 wrx_queue_config
.uuexp
= 0;
4384 wrx_queue_config
.cpiexp
= 0;
4385 wrx_queue_config
.mfs
= aal5r_max_packet_size
;
4386 wrx_queue_config
.oversize
= aal5r_max_packet_size
;
4387 wrx_queue_config
.undersize
= aal5r_min_packet_size
;
4388 wrx_queue_config
.errdp
= aal5r_drop_error_packet
;
4389 wrx_queue_config
.dmach
= RX_DMA_CH_AAL
;
4390 for ( i
= 0; i
< MAX_QUEUE_NUMBER
; i
++ )
4391 *WRX_QUEUE_CONFIG(i
) = wrx_queue_config
;
4392 WRX_QUEUE_CONFIG(OAM_RX_QUEUE
)->dmach
= RX_DMA_CH_OAM
;
4395 * WRX DMA Channel Configuration Table
4397 wrx_dma_channel_config
.chrl
= 0;
4398 wrx_dma_channel_config
.clp1th
= dma_rx_clp1_descriptor_threshold
;
4399 wrx_dma_channel_config
.mode
= 0;
4400 wrx_dma_channel_config
.rlcfg
= 0;
4402 wrx_dma_channel_config
.deslen
= RX_DMA_CH_OAM_DESC_LEN
;
4403 wrx_dma_channel_config
.desba
= ((unsigned int)g_atm_priv_data
.oam_desc
>> 2) & 0x0FFFFFFF;
4404 *WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_OAM
) = wrx_dma_channel_config
;
4406 wrx_dma_channel_config
.deslen
= dma_rx_descriptor_length
;
4407 wrx_dma_channel_config
.desba
= ((unsigned int)g_atm_priv_data
.aal_desc
>> 2) & 0x0FFFFFFF;
4408 *WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_AAL
) = wrx_dma_channel_config
;
4413 for ( i
= 0; i
< MAX_PVC_NUMBER
; i
++ )
4415 htu_result
.qid
= (unsigned int)i
;
4417 *HTU_ENTRY(i
+ OAM_HTU_ENTRY_NUMBER
) = htu_entry
;
4418 *HTU_MASK(i
+ OAM_HTU_ENTRY_NUMBER
) = htu_mask
;
4419 *HTU_RESULT(i
+ OAM_HTU_ENTRY_NUMBER
) = htu_result
;
4422 htu_entry
.vci
= 0x03;
4423 htu_mask
.pid_mask
= 0x03;
4424 htu_mask
.vpi_mask
= 0xFF;
4425 htu_mask
.vci_mask
= 0x0000;
4426 htu_mask
.pti_mask
= 0x07;
4427 htu_result
.cellid
= OAM_RX_QUEUE
;
4428 htu_result
.type
= 1;
4430 htu_result
.qid
= OAM_RX_QUEUE
;
4431 *HTU_RESULT(OAM_F4_SEG_HTU_ENTRY
) = htu_result
;
4432 *HTU_MASK(OAM_F4_SEG_HTU_ENTRY
) = htu_mask
;
4433 *HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY
) = htu_entry
;
4434 htu_entry
.vci
= 0x04;
4435 htu_result
.cellid
= OAM_RX_QUEUE
;
4436 htu_result
.type
= 1;
4438 htu_result
.qid
= OAM_RX_QUEUE
;
4439 *HTU_RESULT(OAM_F4_TOT_HTU_ENTRY
) = htu_result
;
4440 *HTU_MASK(OAM_F4_TOT_HTU_ENTRY
) = htu_mask
;
4441 *HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY
) = htu_entry
;
4442 htu_entry
.vci
= 0x00;
4443 htu_entry
.pti
= 0x04;
4444 htu_mask
.vci_mask
= 0xFFFF;
4445 htu_mask
.pti_mask
= 0x01;
4446 htu_result
.cellid
= OAM_RX_QUEUE
;
4447 htu_result
.type
= 1;
4449 htu_result
.qid
= OAM_RX_QUEUE
;
4450 *HTU_RESULT(OAM_F5_HTU_ENTRY
) = htu_result
;
4451 *HTU_MASK(OAM_F5_HTU_ENTRY
) = htu_mask
;
4452 *HTU_ENTRY(OAM_F5_HTU_ENTRY
) = htu_entry
;
4453 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
4454 htu_entry
.pid
= 0x0;
4455 htu_entry
.vpi
= 0x01;
4456 htu_entry
.vci
= 0x0001;
4457 htu_entry
.pti
= 0x00;
4458 htu_mask
.pid_mask
= 0x0;
4459 htu_mask
.vpi_mask
= 0x00;
4460 htu_mask
.vci_mask
= 0x0000;
4461 htu_mask
.pti_mask
= 0x3;
4462 htu_result
.cellid
= OAM_RX_QUEUE
;
4463 htu_result
.type
= 1;
4465 htu_result
.qid
= OAM_RX_QUEUE
;
4466 *HTU_RESULT(OAM_ARQ_HTU_ENTRY
) = htu_result
;
4467 *HTU_MASK(OAM_ARQ_HTU_ENTRY
) = htu_mask
;
4468 *HTU_ENTRY(OAM_ARQ_HTU_ENTRY
) = htu_entry
;
4472 static INLINE
void init_tx_tables(void)
4475 struct wtx_queue_config wtx_queue_config
= {0};
4476 struct wtx_dma_channel_config wtx_dma_channel_config
= {0};
4477 struct wtx_port_config wtx_port_config
= { res1
: 0,
4484 *CFG_WTX_DCHNUM
= MAX_TX_DMA_CHANNEL_NUMBER
;
4485 *WTX_DMACH_ON
= ((1 << MAX_TX_DMA_CHANNEL_NUMBER
) - 1) ^ ((1 << FIRST_QSB_QID
) - 1);
4486 *CFG_WRDES_DELAY
= write_descriptor_delay
;
4489 * WTX Port Configuration Table
4491 for ( i
= 0; i
< ATM_PORT_NUMBER
; i
++ )
4492 *WTX_PORT_CONFIG(i
) = wtx_port_config
;
4495 * WTX Queue Configuration Table
4497 wtx_queue_config
.qsben
= 1;
4498 wtx_queue_config
.sbid
= 0;
4499 for ( i
= 0; i
< MAX_TX_DMA_CHANNEL_NUMBER
; i
++ ) {
4500 wtx_queue_config
.qsb_vcid
= i
;
4501 *WTX_QUEUE_CONFIG(i
) = wtx_queue_config
;
4505 * WTX DMA Channel Configuration Table
4507 wtx_dma_channel_config
.mode
= 0;
4508 wtx_dma_channel_config
.deslen
= 0;
4509 wtx_dma_channel_config
.desba
= 0;
4510 for ( i
= 0; i
< FIRST_QSB_QID
; i
++ )
4511 *WTX_DMA_CHANNEL_CONFIG(i
) = wtx_dma_channel_config
;
4512 /* normal connection */
4513 wtx_dma_channel_config
.deslen
= dma_tx_descriptor_length
;
4514 for ( ; i
< MAX_TX_DMA_CHANNEL_NUMBER
; i
++ ) {
4515 wtx_dma_channel_config
.desba
= ((unsigned int)g_atm_priv_data
.conn
[i
- FIRST_QSB_QID
].tx_desc
>> 2) & 0x0FFFFFFF;
4516 *WTX_DMA_CHANNEL_CONFIG(i
) = wtx_dma_channel_config
;
4523 * ####################################
4525 * ####################################
4528 static int atm_showtime_enter(struct port_cell_info
*port_cell
, void *xdata_addr
)
4532 ASSERT(port_cell
!= NULL
, "port_cell is NULL");
4533 ASSERT(xdata_addr
!= NULL
, "xdata_addr is NULL");
4535 for ( j
= 0; j
< ATM_PORT_NUMBER
&& j
< port_cell
->port_num
; j
++ )
4536 if ( port_cell
->tx_link_rate
[j
] > 0 )
4538 for ( i
= 0; i
< ATM_PORT_NUMBER
&& i
< port_cell
->port_num
; i
++ )
4539 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
];
4543 for ( i
= 0; i
< MAX_PVC_NUMBER
; i
++ )
4544 if ( g_atm_priv_data
.conn
[i
].vcc
!= NULL
)
4545 set_qsb(g_atm_priv_data
.conn
[i
].vcc
, &g_atm_priv_data
.conn
[i
].vcc
->qos
, i
);
4547 // TODO: ReTX set xdata_addr
4548 g_xdata_addr
= xdata_addr
;
4552 #if defined(CONFIG_VR9)
4553 IFX_REG_W32(0x0F, UTP_CFG
);
4556 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
4557 if ( !timer_pending(&g_retx_polling_timer
) ) {
4558 g_retx_polling_cnt
= HZ
;
4559 g_retx_polling_timer
.expires
= jiffies
+ RETX_POLLING_INTERVAL
;
4560 add_timer(&g_retx_polling_timer
);
4564 //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);
4569 static int atm_showtime_exit(void)
4574 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
4575 RETX_MODE_CFG
->retx_en
= 0; // disable ReTX
4576 del_timer(&g_retx_polling_timer
);
4579 #if defined(CONFIG_VR9)
4580 IFX_REG_W32(0x00, UTP_CFG
);
4585 // TODO: ReTX clean state
4586 g_xdata_addr
= NULL
;
4588 printk("leave showtime\n");
4596 * ####################################
4598 * ####################################
4603 * Initialize global variables, PP32, comunication structures, register IRQ
4604 * and register device.
4609 * else --- failure, usually it is negative value of error code
4611 static int __devinit
ifx_atm_init(void)
4615 struct port_cell_info port_cell
= {0};
4621 ret
= init_priv_data();
4622 if ( ret
!= IFX_SUCCESS
) {
4623 err("INIT_PRIV_DATA_FAIL");
4624 goto INIT_PRIV_DATA_FAIL
;
4627 ifx_atm_init_chip();
4631 /* create devices */
4632 for ( port_num
= 0; port_num
< ATM_PORT_NUMBER
; port_num
++ ) {
4633 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
4634 g_atm_priv_data
.port
[port_num
].dev
= atm_dev_register("ifxmips_atm", &g_ifx_atm_ops
, -1, NULL
);
4636 g_atm_priv_data
.port
[port_num
].dev
= atm_dev_register("ifxmips_atm", NULL
, &g_ifx_atm_ops
, -1, NULL
);
4639 if ( !g_atm_priv_data
.port
[port_num
].dev
) {
4640 err("failed to register atm device %d!", port_num
);
4642 goto ATM_DEV_REGISTER_FAIL
;
4645 g_atm_priv_data
.port
[port_num
].dev
->ci_range
.vpi_bits
= 8;
4646 g_atm_priv_data
.port
[port_num
].dev
->ci_range
.vci_bits
= 16;
4647 g_atm_priv_data
.port
[port_num
].dev
->link_rate
= g_atm_priv_data
.port
[port_num
].tx_max_cell_rate
;
4648 g_atm_priv_data
.port
[port_num
].dev
->dev_data
= (void*)port_num
;
4652 /* register interrupt handler */
4653 ret
= request_irq(PPE_MAILBOX_IGU1_INT
, mailbox_irq_handler
, IRQF_DISABLED
, "atm_mailbox_isr", &g_atm_priv_data
);
4655 if ( ret
== -EBUSY
) {
4656 err("IRQ may be occupied by other driver, please reconfig to disable it.");
4659 err("request_irq fail");
4661 goto REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL
;
4663 disable_irq(PPE_MAILBOX_IGU1_INT
);
4665 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
4666 init_atm_tc_retrans_param();
4668 init_timer(&g_retx_polling_timer
);
4669 g_retx_polling_timer
.function
= retx_polling_func
;
4672 ret
= ifx_pp32_start(0);
4674 err("ifx_pp32_start fail!");
4675 goto PP32_START_FAIL
;
4678 port_cell
.port_num
= ATM_PORT_NUMBER
;
4679 if( !IS_ERR(&ifx_mei_atm_showtime_check
) && &ifx_mei_atm_showtime_check
)
4680 ifx_mei_atm_showtime_check(&g_showtime
, &port_cell
, &g_xdata_addr
);
4682 for ( i
= 0; i
< ATM_PORT_NUMBER
; i
++ )
4683 if ( port_cell
.tx_link_rate
[i
] != 0 )
4685 for ( j
= 0; j
< ATM_PORT_NUMBER
; j
++ )
4686 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
];
4690 validate_oam_htu_entry();
4692 #if 0 /*defined(ENABLE_LED_FRAMEWORK) && ENABLE_LED_FRAMEWORK*/
4693 ifx_led_trigger_register("dsl_data", &g_data_led_trigger
);
4696 /* create proc file */
4699 if( !IS_ERR(&ifx_mei_atm_showtime_enter
) && &ifx_mei_atm_showtime_enter
)
4700 ifx_mei_atm_showtime_enter
= atm_showtime_enter
;
4702 if( !IS_ERR(&ifx_mei_atm_showtime_exit
) && !ifx_mei_atm_showtime_exit
)
4703 ifx_mei_atm_showtime_exit
= atm_showtime_exit
;
4705 ifx_atm_version(ver_str
);
4706 printk(KERN_INFO
"%s", ver_str
);
4708 printk("ifxmips_atm: ATM init succeed\n");
4713 free_irq(PPE_MAILBOX_IGU1_INT
, &g_atm_priv_data
);
4714 REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL
:
4715 ATM_DEV_REGISTER_FAIL
:
4716 while ( port_num
-- > 0 )
4717 atm_dev_deregister(g_atm_priv_data
.port
[port_num
].dev
);
4718 INIT_PRIV_DATA_FAIL
:
4720 printk("ifxmips_atm: ATM init failed\n");
4726 * Release memory, free IRQ, and deregister device.
4732 static void __exit
ifx_atm_exit(void)
4736 if( !IS_ERR(&ifx_mei_atm_showtime_enter
) && &ifx_mei_atm_showtime_enter
)
4737 ifx_mei_atm_showtime_enter
= NULL
;
4738 if( !IS_ERR(&ifx_mei_atm_showtime_exit
) && !ifx_mei_atm_showtime_exit
)
4739 ifx_mei_atm_showtime_exit
= NULL
;
4743 #if 0 /*defined(ENABLE_LED_FRAMEWORK) && ENABLE_LED_FRAMEWORK*/
4744 ifx_led_trigger_deregister(g_data_led_trigger
);
4745 g_data_led_trigger
= NULL
;
4748 invalidate_oam_htu_entry();
4752 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
4753 del_timer(&g_retx_polling_timer
);
4754 clear_atm_tc_retrans_param();
4757 free_irq(PPE_MAILBOX_IGU1_INT
, &g_atm_priv_data
);
4759 for ( port_num
= 0; port_num
< ATM_PORT_NUMBER
; port_num
++ )
4760 atm_dev_deregister(g_atm_priv_data
.port
[port_num
].dev
);
4762 ifx_atm_uninit_chip();
4767 module_init(ifx_atm_init
);
4768 module_exit(ifx_atm_exit
);
4769 MODULE_LICENSE("Dual BSD/GPL");