mpc860sar Project Page | CVS web interface |
Rodolfo Giometti (giometti at linux dot it) Feb 3tr 2004
Version 0.1
Alex Zeffertt Nov 9th 2001 (ajz at sourceforge dot net)
The driver has only been tested with v2.4.4 and v2.4.17 linux kernels.
The driver can be built as either a resident driver or a loadable module.
Since release 2.3 the driver also supports Multi-PHY but only for CPUs with SAR engine (the tests was made with a MPC850SAR with two PHYs). I beleave it's not too much work adding the MultiPHY support for ESAR.
The driver conforms to the "Linux ATM device driver interface Draft, version 0.1" (Werner Almesberger).
I have also ported the ATM tools (atm-0.79) to the PPC.
> # Install Montavista CDK 2.0 development kit (contains cross > # compiler) > # IF you already have a previous version of the CDK (e.g. v1.2) > # THEN you will need to uninstall this first > rpm -qa | grep hhl # finds out which hardhat RPMs are already installed > rpm -e hhl-xxx # repeat for each rpm listed previously > # sometimes you need to do this twice .... > rpm -qa | grep hh # confirm all deleted > # install v2.0 of CDK > mount /mnt/cdrom > cd /mnt/cdrom/bin > > ./hhl-host-install ... enter "?" to display LSP names ... ... select appropriate compiler ...
> cd your-existing-linux-ppc-kernel/ # I've only tested this on v2.4.4 kernels
Extract the atm driver
> cd arch/ppc/ > tar -xzf path-to-file/atm-xxxx-xx-xx.tgz # replace with actual name of fileYou should now see the driver in arch/ppc/atm/. You will need to make some modifications to some other files before attempting to compile.
1. In linux/Makefile: Change "CROSS_COMPILE" to "ppc_8xx-" (i.e. the tools installed with CDK 2.0). 2. In linux/arch/ppc/Makefile: Add in the lines marked "+" ifdef CONFIG_8xx SUBDIRS += arch/ppc/8xx_io DRIVERS += arch/ppc/8xx_io/8xx_io.o + SUBDIRS += arch/ppc/atm + DRIVERS += arch/ppc/atm/atm.o endif 3. In linux/arch/ppc/config.in: Add in the lines marked "+" source arch/ppc/8xx_io/Config.in + if [ "$CONFIG_ATM" = "y" ]; then + source arch/ppc/atm/Config.in + fi 4. In linux/arch/ppc/kernel/ppc_ksyms.c: Add in the line marked "+" #ifdef CONFIG_8xx + EXPORT_SYMBOL(va_to_pte); 5. Copy the text in linux/arch/ppc/atm/Configure.help.frag to linux/Documentation/Configure.help just before the comment lines at the end. 6. If, you are using MII then you will need to make sure it uses port A and not port D. To do this you may need to modify the way the following register fields are set up in linux/arch/ppc/8xx_io/fec.c to ensure that the MII still works after you've added the ATM driver. PDPAR[UT] ECNTRL[FEC_PINMUX] UTMODE[SPLIT] See table 41-6 OF MPC862UM.PDF.Now configure your kernel (change options - if neccessary - to appear as below).
> make config * * MPC8xxSAR ATM CPM Options * MPC86x/MPC855T(Rev E)/MPC850 (ATM) support (CONFIG_8XX_ATM) [N/y/m/?] MPC8xx mode (SAR, ESAR) [ESAR] * * UTOPIA port config * UTOPIA ATM support (CONFIG_UTOPIA) [N/y/?] UTOPIA PHY (SUNI_ULTRA, IDT77V106, Other_PHY) [SUNI_ULTRA] * * UTOPIA minimum channel rates for the utopia device * UTOPIA minimum channel rate (32Kbs, 1Mbs) [1Mbs] * * UTOPIA MPHYs settings * * * Serial port config * Serial ATM support (CONFIG_SERIAL_ATM) [Y/n/?] SCC used (1-3) (CONFIG_SERIAL_ATM_SCC) [1] Use SI in TSA mode (CONFIG_SERIAL_ATM_TSA) [M/n/?] Which TDM to map to SCC using TSA (TDMa, TDMb) [TDMa] defined CONFIG_SERIAL_ATM_TDMA Use SI in NMSI mode (CONFIG_SERIAL_ATM_NMSI) [M/n/?] CLK to use for RCLK and TCLK (1-4 for SCC1/2, 5-8 for SCC3/4) (CONFIG_SERIAL_ATM_NMSI_CLKPIN) [1] * * ATM switching * Port to Port Switching (CONFIG_PTP_SWITCHING) [Y/n/?] Build the makefile dependencies (used by make) > make depend Build the image used by PPCBoot NOTE If this complains that it can't find "mkimage" then you will need to Build and install PPCBoot (see below) and then try again. > make pImage If you selected M for "MPC86x/MPC855T(Rev E) ESAR (ATM) support", then you will now need to build the modules. > make modules The ATM module is built in linux/arch/ppc/atm/atm-8xx.o. If CONFIG_UTOPIA was selected then you may have built one or more of the following PHY modules: linux/arch/ppc/atm/suni.o linux/arch/ppc/atm/idt77106.o linux/arch/ppc/atm/generic_phy.oAs you can see above for "UTOPIA minimum channel rate" you can choose between "32Kbs" and "1Mbs" (Rodolfo added this selection for its MPC850SAR but you should carefully set this parameter to fit your needs).
If you choose ESAR support you will __not__ be prompted for the Utopia MPHY support (see the above example) since this is currently implemented only for SAR support.
If CONFIG_SERIAL_ATM was selected then you may have built one or more of the following serial PHY modules:
linux/arch/ppc/atm/tsa.o linux/arch/ppc/atm/nmsi.o
> # build ppcboot (to get mkimage) > # Get original version of code > bzip2 -cd ppcboot-1.1.0.tar.bz2 | tar xf - > # change the compiler used > cd ppcboot/ > emacs Makefile # change line 36 to "CROSS_COMPILE = ppc_8xx-" > # put "." in your path (this is a workaround to a problem only in v1.1.0) > PATH=$PATH:. > # choose config > make YOUR_config > # build ./ppcboot.bin and ./tools/mkimage > make clean > make depend > make all > # Make mkimage available > cp tools/mkimage /usr/bin
> # untar latest tools (replace x's with date of most current tools) > tar -xzf atm-0.79.ppc-xxxx-xx-xx.tgz > cd atm-0.79.ppc/ > # build > make clean > make depend > make
Configure minicom for 9600 8N1 COMM1
> # Run minicom > minicomConnect power to board
If nothing is output to minicom then you will need to load PPCBoot into FLASH. How to do this will depend on your particular board.
If the following is output ...
PPCBoot 1.0.4 (Oct 15 2001 - 13:59:31) CPU: unknown MPC860 (0x06000000) at 80 MHz: 16 kB I-Cache 8 kB D-Cache FEC prt *** Warning: CPU Core has Silicon Bugs -- Check the Errata *** Board: YOUR Board DRAM: (32 MB SDRAM) 32 MB FLASH: 16 MB In: serial Out: serial Err: serialThen you already have PPCBoot.
=># Find out if enviroment is already correct: =>printenv ... =># If not, then do following (replace each "[]" with your own text) =>setenv ipaddr [ipaddr of board] =>setenv serverip [ipaddr of PC on which CDK was installed] =>setenv autostart yes =>setenv bootdelay 1 =>setenv ethaddr [a mac addr from daves list of free ones (format aa:bb:cc:dd:ee:ff)] =>setenv bootargs root=/dev/nfs rw nfsroot=[serverip]:/opt/hardhat/devkit/ppc/8xx/target/ nfsaddrs=[ipaddr]:10.0.0 =>setenv bootcmd tftpboot =># Save enviroment to flash =>saveenv
> # export the hardhat root FS > echo "/opt/hardhat/devkit/ppc/8xx/target (rw,no_root_squash,no_all_squash)" > /etc/exports > exportfs > /etc/rc.d/init.d/nfs restart > # Stick link to kernel image in default position > ln -s path-to-linux/arch/ppc/mbxboot/pImage /tftpboot/5300000A.img > # This gets picked up by an board > # with ipaddr 10.0.0.83 so you'll > # need to change "5300000A.img" to > # something else.
Connect serial to PC and run minicom.
Finally connect power to board - it should load PPCBoot, which should automatically tftp new pImage and run it. The kernel should then automatically NFS mount /opt/hardhat/devkit/ppc/8xx/target as root filesystem.
If you built the driver as a module then you will need to insmod the modules:
If CONFIG_UTOPIA was selected then you must insmod exactly one of
insmod generic_phy.o pcr=100000
If CONFIG_SERIAL_ATM was selected then you must insmod exactly one of
If nmsi.o is used then serial ATM will be transmitted over the Non-Multiplexed Serial Interface of whichever SCC is selected for serial ATM.
Both tsa and nmsi can optionally be used with a module parameter "serial_loopback". E.g.
insmod tsa.o serial_loopback=1
internally loops back the serial interface.
Finally, you must insmod atm-8xx.o. This action actually starts the ATM driver.
The modules atm-8xx.o comes with two module parameters:
insmod utopia_log2_vpi_ubound=1 serial_log2_vpi_ubound=3
will make the ATM driver support VPIs 0-1 on the UTOPIA port, and VPIs 0-7 on the serial port.
> # move test programs to root FS > cd path-to-atm-0.79.ppc/test/ > for file in *; if [ -x $file ] ; then cp $file /opt/hardhat/devkit/ppc/8xx/target/bin ; fi ; doneTo test AAL5:
On minicom: > aread -c 0.0.32 On PC > awrite 0.0.32 "hello" (or vice versa)To test AAL0:
On minicom > 0read 0.0.32 On PC > 0write 0.0.32 "hello" (or vice versa)To test throughput:
Connect the utopia PHY in loopback mode. Then, in minicom: > cd /bin > aburst USAGE: aburst --addr itf.vpi.vci\ --tt {ubr|cbr} --aal {0|5} [--datalen datalen]\ [--pcr pcr] [--random] [--ping] Notes: pcr is required if cbr is selected datalen is required if aal 5 is selected If you run aburst in --ping mode it will 10 cells/frames in the air at any one time, it will assume if it hasn't received any cells/frames in 0.1 seconds that all currently in the air have been lost, and it will print out: o the current total cells/frames received (granularity = 1024) o the current total cells/frames lost (granularity = 10) > # Example: > # Find the total loopback throughput using CBR/AAL5/20cellframes/maxPCR45000 > aburst --ping --addr 0.0.32 --tt cbr --pcr 45000 --aal 5 --datalen $(echo $[48*(20-1)]) & sleep 10; killall aburst frames recvd=0x5000 lost=0x0 > echo $[(0x5000*53*8)/30] # Prints out throughput
To set this up do the following:
On PC:
> # If not already done download atm-0.79.tar.gz from the web, and build > tar -xzf atm-0.79.tar.gz > # This is from atm/USAGE > cd ../atm > make depend > make > make install > # Now set up CLIP on PC > atmarpd & # start the atmarp daemon > atmarp -c # create IP i/f called atm0 > ifconfig atm0 192.168.0.1 # give atm0 an IP address > atmarp -s 192.168.0.254 0.0.100 # tell atmarpd which PVC to use for board > # Now copy ported tools to boards root FS > cp -r cd path-to-atm-0.79.ppc/arpd /binOn board via minicom:
> # Now set up CLIP on board > cd /bin/arpd/ > ./atmarpd & # start the atmarp daemon > ./atmarp -c # create IP i/f called atm0 > ifconfig atm0 192.168.0.254 # give atm0 an IP address > ./atmarp -s 192.168.0.1 0.0.100 # tell atmarpd which PVC to use for PCFinally...
On PC:
> ping 192.168.0.254On board:
> ping 192.168.0.1
This means that you should be able to do tests like this
> aburst --ping --addr 1.0.32 --tt ubr --aal 0for example.
HOWEVER, to do this you need a generate clock signal into L1RCLKa (TDMa's clock input) and a 128 bit sync input on L1RSYNCa (TDMa's sync input):
____ ____ L1RSYNCa __ ____________________ .....______ ______ __ __ __ __ __ __ _..... __ __ __ __ L1RCLKa __ __ __ __ __ __ __ .....__ __ __ __ ^<---------------128 bits---------->^ start of frame start of next frameYou will also need to modify SERIAL_PHY_BITRATE in serial.c
This means that you should be able to do tests like this
> aburst --ping --addr 1.0.32 --tt ubr --aal 0for example.
HOWEVER, to do this you need a generate clock signal into CLKx (where x = CONFIG_SERIAL_ATM_NMSI_CLKPIN) You will also need to modify SERIAL_PHY_BITRATE in serial.c
Make the h/w mods required to use the TDMa in loopback mode (see above section).
Connect the board to the PC via UTOPIA-PHY-ATM.
In minicom:
> # Set up three CBR PVCs > echo "add 0.0.32 1.0.32 18000 cbr" > /proc/switch > echo "add 1.0.32 0.0.32 18000 cbr" > /proc/switch > echo "add 0.0.110 0.0.110 45000 cbr" > /proc/switch > # Confirm that the PVCs were set up correctly > cat /proc/switch inputVC outputVC PCR traffic-type ====================================== 0.0.32 1.0.32 18000 cbr 1.0.32 0.0.32 18000 cbr 0.0.110 0.0.110 45000 cbrOn PC:
> # Build aburst for the PC > cp ~/atm-0.79.ppc/test/aburst.c ~/atm-0.79.ppc/test/Makefile /usr/src/atm/test/ > cd /usr/src/atm/test; > make aburst;To test switching using only the UTOPIA:
On PC:
> aburst --ping --addr 0.0.110 --tt ubr --aal 5 --datalen 1To test switching using both the UTOPIA and the SERIAL:
On PC:
> aburst --ping --addr 0.0.32 --tt ubr --aal 5 --datalen 1
Each struct atm_dev structure has a pointer to some driver specific data called dev_data. In my driver this data is a dev_data_t struct.
Each struct atm_vcc structure has a pointer to some driver specific data called dev_data. In my driver this data is a cpm_channel_t struct. This struct is also used for the raw cell queue which is not tied to an struct atm_vcc.
Switched PVCs are created via the /proc/switch interface and consequently do not have an associated atm_vcc struct. Instead the driver uses a sw_pvc_t structure.
Channel number 0 is used for the Raw Cell Queue (RCQ). This is mandated by the 862UM. Channels 1-31, however, are never used by terminated channels. Instead, the first terminated PVC is given channel number 32. Channels numbered 0-31 use Connection Tables (CTs) in Dual Port RAM (DPRAM), whereas channels numbered 32 up use CTs in external memory. Therefore we use the higher channel numbers where possible to save on DPRAM (which is running short).
The driver uses 2 APC levels per port. The first is used for sheduling CBR channels; the second is used for scheduling UBR channels. The CBR channels are activated (placed in APC sheduling table 1) when the PVC opened. They are only deactivated when the PVC is closed. The total booked bandwidth for APC level 1 is monitored and the driver will not overbook. Therefore APC Overrun events should not occur on APC level 1, and if they do the driver takes the drastic measure of stopping the APC tick (CPM timer 4). The timer is only restarted by a further send().
The UBR channels are activated (placed in APC scheduling table 2) by send() whenever it detects that the channel is not already active. The intention was that the channel was deactivated by Auto VC Off (AVCF) whenever the CPM detected there was no further data to send from that channel. However, this appears to be broken (the CPM always clears the TCT[ACT] bit whether the channel has be removed from APC scheduling table 2 or not - see errata.h). Therefore the driver does not use AVCF. Instead, each time it gets a tx buffer done interrupt on a UBR channel, the driver checks to see if there are any further buffers to send, and if not deactivates the channel in software.
When a UBR channel is created it is scheduled at the maximum possible rate (i.e. PCR=min(APC tick rate,PHY cell rate)). Therefore sending on several UBR channels simultaneously, or opening a CBR channel and sending on a UBR channel simultaneously, is liable to cause APC Overrun events on the APC sheduling table 2. These are ignored by the s/w and are (probably) harmless.
When a serial ATM driver on (say) TDMa is configured, the code in serial.c must configure the Time Slot Assigner to make a request to the SCC every frame. The driver configures the TSA to expect 16 byte frames on TDMa. This frame size was chosen because it is the maximum (single entry) frame size configurable (see MPC862UM section on SI). This means that the TSA makes less frequent DMA requests to SCC, and this reduces CPM load.
When a Port To Port (PTP) switched channel is created the driver allocates a PTP Receive Connection Table (PTPRCT) on the receiving port and a PTP Transmit Connection Table (PTPTCT) on the transmitting port. It then points the PTPRCT at the PTPTCT. No host intervention is then required on a per cell basis.
All of the above (with SERIAL replaced by UTOPIA)
In mpc860sar.h: