dag.sh.in 2.78 KB
Newer Older
's avatar
committed
1
2
3
4
5
6
#!/bin/bash

DAGDIR=@DAG_DIR@
DAGFWDIR=${DAGDIR}/share/dag/xilinx

function usage() {
7
   echo "dag.sh { 4.3 | 6.2 | 8.2 ] [ <card_number> ] [ -f ] [ -p ] }"
's avatar
committed
8
   echo ""
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
   echo "<card_number> is x in /dev/dagx. Default is 0."
	echo "-f     only reload firmware (do not reload driver)"
	echo "-p     enable PPS output from the card"
	echo ""
	echo "If there are more DAG cards in a PC then:"
	echo "initialize one card without -f (reload both driver and firmware)"
	echo "and initialize other cards with -f (reload only firmware)"
	echo ""
	echo "Example DAG4.3 (/dev/dag0) + DAG8.2 (/dev/dag1 + /dev/dag2):"
	echo "dag.sh 4.3"
	echo "dag.sh 8.2 1 -f"
	echo ""
	echo "Example DAG8.2 (/dev/dag0 + /dev/dag1) + DAG8.2 (/dev/dag2 + /dev/dag3):"
	echo "dag.sh 8.2 -p"
	echo "dag.sh 8.2 2 -f"
's avatar
committed
24
25
26
27
28
29
30
31
32
33
}

if [ $# -lt 1 ]; then
  usage
  exit
fi

# Determine card type

if [ $1 = "4.3" -o $1 = "6.2" -o $1 = "8.2" ]; then
34
  CARD_TYPE=$1
's avatar
committed
35
36
  shift
else
37
  echo "Unsupported card type"
's avatar
committed
38
  usage
39
  exit -1
's avatar
committed
40
41
fi

42
# Determine the card number
's avatar
committed
43

44
CARD_NO=0
's avatar
committed
45
if [ $# -gt 0 ]; then
46
47
48
49
50
51
	if [ ${1:0:1} != "-" ]; then
   	if [ $1 -ge 0 -a $1 -le 255 ]; then
      	CARD_NO=$1
			shift
   	fi
	fi
's avatar
committed
52
53
fi

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
RELOAD_DRIVER=1
if [ $# -gt 0 ]; then
	if [ $1 == "-f" ]; then
		RELOAD_DRIVER=0
		shift
	fi
fi

PPS_OUT=1
if [ $# -gt 0 ]; then
	if [ $1 == "-p" ]; then
		PPS_OUT=1
	else
		echo "Unknown argument"
		usage
		exit -1
	fi
fi
's avatar
committed
72

73
74
75
76
echo "CARD_TYPE: $CARD_TYPE"
echo "CARD_NO: $CARD_NO"
echo "RELOAD_DRIVER: $RELOAD_DRIVER"
echo "PPS_OUT: $PPS_OUT"
's avatar
committed
77

78
79
80
if [ $RELOAD_DRIVER -gt 0 ]; then
	rmmod dag
	rmmod dagmem
's avatar
committed
81

82
83
	KERNEL_VERSION=`uname -r`
	KERNEL_V4V6=`echo $KERNEL_VERSION | awk -F. '{print $2}'`
's avatar
committed
84

85
86
87
88
89
90
91
92
93
94
	#if [ $KERNEL_V4V6 = "6" ]; then
	#  insmod /lib/modules/${KERNEL_VERSION}/extra/dagmem.ko dsize=128M
	#else
  		modprobe dagmem dsize=128M
	#fi

	dagload
fi

if [ $CARD_TYPE = "4.3" ]; then
's avatar
committed
95
  # The following firmware supports transmitting, but not filtering
96
97
98
  # dagrom -rvp -d /dev/dag${CARD_NO} -f ${DAGFWDIR}/dag43gepcix-terf.bit
  dagrom -rvp   -d /dev/dag${CARD_NO} -f ${DAGFWDIR}/dag43gepcix-ipf.bit
  dagld -x      -d /dev/dag${CARD_NO}    ${DAGFWDIR}/copro-ipf43ge.bit
's avatar
committed
99
  dagfour default nic slen=1520
100
101
102
elif [ $CARD_TYPE = "6.2" ]; then
  dagrom -rvp   -d /dev/dag${CARD_NO} -f ${DAGFWDIR}/dag62pcix-erf.bit
  dagld -x      -d /dev/dag${CARD_NO}    ${DAGFWDIR}/dag62rx-erf.bit
's avatar
committed
103
  dagsix default eth lan slen=1520 long=1520
104
105
106
107
108
109
elif [ $CARD_TYPE = "8.2" ]; then
  SECOND_INTERNAL_DEVICE=`expr $CARD_NO + 1`
  dagrom -rvp   -d${CARD_NO} -f ${DAGFWDIR}/dag82xpci-terf-dsm.bit
  dagconfig -d${CARD_NO} default
  dagconfig -d${SECOND_INTERNAL_DEVICE} default
  dagconfig -d${CARD_NO} slen=1520 mem=128:0 
's avatar
committed
110
else
111
112
113
114
115
116
117
118
  echo "Unsupported card type"
  usage
  exit -1
fi

# Enable PPS output from the first card (can be used by the second card)
if [ ${PPS_OUT} -gt 0 ]; then
    dagclock -d${CARD_NO} overout
's avatar
committed
119
fi