OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [ethmac/] [sim/] [ethmac-rxtxcallresponse.c] - Blame information for rev 669

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 411 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Interrupt-driven Ethernet MAC transmit test code            ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  Send packets while receiving packets                        ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - jb, jb@orsoc.se, with parts taken from Linux kernel   ////
10
////        open_eth driver.                                      ////
11
////                                                              ////
12
////                                                              ////
13
//////////////////////////////////////////////////////////////////////
14
////                                                              ////
15
//// Copyright (C) 2009 Authors and OPENCORES.ORG                 ////
16
////                                                              ////
17
//// This source file may be used and distributed without         ////
18
//// restriction provided that this copyright statement is not    ////
19
//// removed from the file and that any derivative work contains  ////
20
//// the original copyright notice and the associated disclaimer. ////
21
////                                                              ////
22
//// This source file is free software; you can redistribute it   ////
23
//// and/or modify it under the terms of the GNU Lesser General   ////
24
//// Public License as published by the Free Software Foundation; ////
25
//// either version 2.1 of the License, or (at your option) any   ////
26
//// later version.                                               ////
27
////                                                              ////
28
//// This source is distributed in the hope that it will be       ////
29
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
30
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
31
//// PURPOSE.  See the GNU Lesser General Public License for more ////
32
//// details.                                                     ////
33
////                                                              ////
34
//// You should have received a copy of the GNU Lesser General    ////
35
//// Public License along with this source; if not, download it   ////
36
//// from http://www.opencores.org/lgpl.shtml                     ////
37
////                                                              ////
38
//////////////////////////////////////////////////////////////////////
39
 
40
#include "cpu-utils.h"
41
#include "board.h"
42
#include "int.h"
43
#include "ethmac.h"
44
#include "eth-phy-mii.h"
45
 
46
volatile unsigned tx_done;
47
volatile unsigned rx_done;
48
static int next_tx_buf_num;
49
 
50
/* Functions in this file */
51
void ethmac_setup(void);
52
/* Interrupt functions */
53
void oeth_interrupt(void);
54
static void oeth_rx(void);
55
static void oeth_tx(void);
56
 
57
/* Let the ethernet packets use a space beginning here for buffering */
58
#define ETH_BUFF_BASE 0x01000000
59
 
60
 
61
#define RXBUFF_PREALLOC 1
62
#define TXBUFF_PREALLOC 1
63
//#undef RXBUFF_PREALLOC
64
//#undef TXBUFF_PREALLOC
65
 
66
/* The transmitter timeout
67
*/
68
#define TX_TIMEOUT      (2*HZ)
69
 
70
/* Buffer number (must be 2^n)
71
*/
72
#define OETH_RXBD_NUM           16
73
#define OETH_TXBD_NUM           16
74
#define OETH_RXBD_NUM_MASK      (OETH_RXBD_NUM-1)
75
#define OETH_TXBD_NUM_MASK      (OETH_TXBD_NUM-1)
76
 
77
/* Buffer size
78
*/
79
#define OETH_RX_BUFF_SIZE       0x600-4
80
#define OETH_TX_BUFF_SIZE       0x600-4
81
 
82
/* Buffer size  (if not XXBUF_PREALLOC
83
*/
84
#define MAX_FRAME_SIZE          1518
85
 
86
/* The buffer descriptors track the ring buffers.
87
*/
88
struct oeth_private {
89
  //struct      sk_buff* rx_skbuff[OETH_RXBD_NUM];
90
  //struct      sk_buff* tx_skbuff[OETH_TXBD_NUM];
91
 
92
  unsigned short        tx_next; /* Next buffer to be sent */
93
  unsigned short        tx_last; /* Next buffer to be checked if packet sent */
94
  unsigned short        tx_full; /* Buffer ring fuul indicator */
95
  unsigned short        rx_cur;  /* Next buffer to be checked if packet
96
                                    received */
97
 
98
  oeth_regs     *regs;                  /* Address of controller registers. */
99
  oeth_bd               *rx_bd_base;            /* Address of Rx BDs. */
100
  oeth_bd               *tx_bd_base;            /* Address of Tx BDs. */
101
 
102
  //    struct net_device_stats stats;
103
};
104
 
105
#define PHYNUM 7
106
 
107
// Data array of data to transmit, tx_data_array[]
108
//#include "eth-rxtx-data.h" // Not used
109
int tx_data_pointer;
110
 
111
 
112
void
113
eth_mii_write(char phynum, short regnum, short data)
114
{
115
  static volatile oeth_regs *regs = (oeth_regs *)(OETH_REG_BASE);
116
  regs->miiaddress = (regnum << 8) | phynum;
117
  regs->miitx_data = data;
118
  regs->miicommand = OETH_MIICOMMAND_WCTRLDATA;
119
  regs->miicommand = 0;
120
  while(regs->miistatus & OETH_MIISTATUS_BUSY);
121
}
122
 
123
short
124
eth_mii_read(char phynum, short regnum)
125
{
126
  static volatile oeth_regs *regs = (oeth_regs *)(OETH_REG_BASE);
127
  regs->miiaddress = (regnum << 8) | phynum;
128
  regs->miicommand = OETH_MIICOMMAND_RSTAT;
129
  regs->miicommand = 0;
130
  while(regs->miistatus & OETH_MIISTATUS_BUSY);
131
 
132
  return regs->miirx_data;
133
}
134
 
135
 
136
 
137
// Wait here until all packets have been transmitted
138
void
139
wait_until_all_tx_clear(void)
140
{
141
  int i;
142
  volatile oeth_bd *tx_bd;
143
  tx_bd = (volatile oeth_bd *)OETH_BD_BASE; /* Search from beginning*/
144
 
145
  int some_tx_waiting = 1;
146
 
147
  while (some_tx_waiting)
148
    {
149
      some_tx_waiting = 0;
150
      /* Go through the TX buffs, search for unused one */
151
      for(i = 0; i < OETH_TXBD_NUM; i++) {
152
 
153
        // Looking for buffer ready for transmit
154
        if((tx_bd[i].len_status & OETH_TX_BD_READY))
155
          some_tx_waiting = 1;
156
 
157
      }
158
    }
159
}
160
 
161
 
162
void
163
ethphy_set_10mbit(int phynum)
164
{
165
  wait_until_all_tx_clear();
166
  // Hardset PHY to just use 10Mbit mode
167
  short cr = eth_mii_read(phynum, MII_BMCR);
168
  cr &= ~BMCR_ANENABLE; // Clear auto negotiate bit
169
  cr &= ~BMCR_SPEED100; // Clear fast eth. bit
170
  eth_mii_write(phynum, MII_BMCR, cr);
171
}
172
 
173
 
174
void
175
ethphy_set_100mbit(int phynum)
176
{
177
  wait_until_all_tx_clear();
178
  // Hardset PHY to just use 100Mbit mode
179
  short cr = eth_mii_read(phynum, MII_BMCR);
180
  cr |= BMCR_ANENABLE; // Clear auto negotiate bit
181
  cr |= BMCR_SPEED100; // Clear fast eth. bit
182
  eth_mii_write(phynum, MII_BMCR, cr);
183
}
184
 
185
 
186
void
187
ethmac_setup(void)
188
{
189
  // from arch/or32/drivers/open_eth.c
190
  volatile oeth_regs *regs;
191
 
192
  regs = (oeth_regs *)(OETH_REG_BASE);
193
 
194
  /* Reset MII mode module */
195
  regs->miimoder = OETH_MIIMODER_RST; /* MII Reset ON */
196
  regs->miimoder &= ~OETH_MIIMODER_RST; /* MII Reset OFF */
197
  regs->miimoder = 0x64; /* Clock divider for MII Management interface */
198
 
199
  /* Reset the controller.
200
  */
201
  regs->moder = OETH_MODER_RST; /* Reset ON */
202
  regs->moder &= ~OETH_MODER_RST;       /* Reset OFF */
203
 
204
  /* Setting TXBD base to OETH_TXBD_NUM.
205
  */
206
  regs->tx_bd_num = OETH_TXBD_NUM;
207
 
208
 
209
  /* Set min/max packet length
210
  */
211
  regs->packet_len = 0x00400600;
212
 
213
  /* Set IPGT register to recomended value
214
  */
215
  regs->ipgt = 0x12;
216
 
217
  /* Set IPGR1 register to recomended value
218
  */
219
  regs->ipgr1 = 0x0000000c;
220
 
221
  /* Set IPGR2 register to recomended value
222
  */
223
  regs->ipgr2 = 0x00000012;
224
 
225
  /* Set COLLCONF register to recomended value
226
  */
227
  regs->collconf = 0x000f003f;
228
 
229
  /* Set control module mode
230
  */
231
#if 0
232
  regs->ctrlmoder = OETH_CTRLMODER_TXFLOW | OETH_CTRLMODER_RXFLOW;
233
#else
234
  regs->ctrlmoder = 0;
235
#endif
236
 
237
  /* Clear MIIM registers */
238
  regs->miitx_data = 0;
239
  regs->miiaddress = 0;
240
  regs->miicommand = 0;
241
 
242
  regs->mac_addr1 = ETH_MACADDR0 << 8 | ETH_MACADDR1;
243
  regs->mac_addr0 = ETH_MACADDR2 << 24 | ETH_MACADDR3 << 16 | ETH_MACADDR4 << 8 | ETH_MACADDR5;
244
 
245
  /* Clear all pending interrupts
246
  */
247
  regs->int_src = 0xffffffff;
248
 
249
  /* Promisc, IFG, CRCEn
250
  */
251
  regs->moder |= OETH_MODER_PRO | OETH_MODER_PAD | OETH_MODER_IFG | OETH_MODER_CRCEN | OETH_MODER_FULLD;
252
 
253
  /* Enable interrupt sources.
254
  */
255
 
256
  regs->int_mask = OETH_INT_MASK_TXB    |
257
    OETH_INT_MASK_TXE   |
258
    OETH_INT_MASK_RXF   |
259
    OETH_INT_MASK_RXE   |
260
    OETH_INT_MASK_BUSY  |
261
    OETH_INT_MASK_TXC   |
262
    OETH_INT_MASK_RXC;
263
 
264
  // Buffer setup stuff
265
  volatile oeth_bd *tx_bd, *rx_bd;
266
  int i,j,k;
267
 
268
  /* Initialize TXBD pointer
269
  */
270
  tx_bd = (volatile oeth_bd *)OETH_BD_BASE;
271
 
272
  /* Initialize RXBD pointer
273
  */
274
  rx_bd = ((volatile oeth_bd *)OETH_BD_BASE) + OETH_TXBD_NUM;
275
 
276
  /* Preallocated ethernet buffer setup */
277
  unsigned long mem_addr = ETH_BUFF_BASE; /* Defined at top */
278
 
279
  // Setup TX Buffers
280
  for(i = 0; i < OETH_TXBD_NUM; i++) {
281
    //tx_bd[i].len_status = OETH_TX_BD_PAD | OETH_TX_BD_CRC | OETH_RX_BD_IRQ;
282
    tx_bd[i].len_status = OETH_TX_BD_PAD | OETH_TX_BD_CRC;
283
    tx_bd[i].addr = mem_addr;
284
    mem_addr += OETH_TX_BUFF_SIZE;
285
  }
286
  tx_bd[OETH_TXBD_NUM - 1].len_status |= OETH_TX_BD_WRAP;
287
 
288
  // Setup RX buffers
289
  for(i = 0; i < OETH_RXBD_NUM; i++) {
290
    rx_bd[i].len_status = OETH_RX_BD_EMPTY | OETH_RX_BD_IRQ; // Init. with IRQ
291
    rx_bd[i].addr = mem_addr;
292
    mem_addr += OETH_RX_BUFF_SIZE;
293
  }
294
  rx_bd[OETH_RXBD_NUM - 1].len_status |= OETH_RX_BD_WRAP; // Last buffer wraps
295
 
296
  /* Enable RX and TX in MAC
297
  */
298
  regs->moder &= ~(OETH_MODER_RXEN | OETH_MODER_TXEN);
299
  regs->moder |= OETH_MODER_RXEN | OETH_MODER_TXEN;
300
 
301
  next_tx_buf_num = 0; // init tx buffer pointer
302
 
303
  return;
304
}
305
 
306
// Enable RX in ethernet MAC
307
void
308
oeth_enable_rx(void)
309
{
310
  volatile oeth_regs *regs;
311
  regs = (oeth_regs *)(OETH_REG_BASE);
312
  regs->moder |= OETH_MODER_RXEN;
313
}
314
 
315
// Disable RX in ethernet MAC
316
void
317
oeth_disable_rx(void)
318
{
319
  volatile oeth_regs *regs;
320
  regs = (oeth_regs *)(OETH_REG_BASE);
321
  regs->moder &= ~(OETH_MODER_RXEN);
322
}
323
 
324
 
325
/* Setup buffer descriptors with data */
326
/* length is in BYTES */
327
void tx_packet(void* data, int length)
328
{
329
  volatile oeth_regs *regs;
330
  regs = (oeth_regs *)(OETH_REG_BASE);
331
 
332
  volatile oeth_bd *tx_bd;
333
  volatile int i;
334
 
335
  tx_bd = (volatile oeth_bd *)OETH_BD_BASE;
336
  tx_bd = (struct oeth_bd*) &tx_bd[next_tx_buf_num];
337
 
338
  // If it's in use - wait
339
  while ((tx_bd->len_status & OETH_TX_BD_IRQ));
340
 
341
  /* Clear all of the status flags.
342
  */
343
  tx_bd->len_status &= ~OETH_TX_BD_STATS;
344
 
345
  /* If the frame is short, tell CPM to pad it.
346
  */
347
#define ETH_ZLEN        60   /* Min. octets in frame sans FCS */
348
  if (length <= ETH_ZLEN)
349
    tx_bd->len_status |= OETH_TX_BD_PAD;
350
  else
351
    tx_bd->len_status &= ~OETH_TX_BD_PAD;
352
 
353
#ifdef _ETH_RXTX_DATA_H_
354
  // Set the address pointer to the place
355
  // in memory where the data is and transmit from there
356
 
357
  tx_bd->addr = (char*) &tx_data_array[tx_data_pointer&~(0x3)];
358
 
359
  tx_data_pointer += length + 1;
360
  if (tx_data_pointer > (255*1024))
361
    tx_data_pointer = 0;
362
 
363
 
364
#else
365
  if (data){
366
    //Copy the data into the transmit buffer, byte at a time 
367
    char* data_p = (char*) data;
368
    char* data_b = (char*) tx_bd->addr;
369
    for(i=0;i<length;i++)
370
      {
371
        data_b[i] = data_p[i];
372
      }
373
  }
374
#endif
375
 
376
  /* Set the length of the packet's data in the buffer descriptor */
377
  tx_bd->len_status = (tx_bd->len_status & 0x0000ffff) |
378
    ((length&0xffff) << 16);
379
 
380
  /* Send it on its way.  Tell controller its ready, interrupt when sent
381
  * and to put the CRC on the end.
382
  */
383
  tx_bd->len_status |= (OETH_TX_BD_READY  | OETH_TX_BD_CRC | OETH_TX_BD_IRQ);
384
 
385
  next_tx_buf_num = (next_tx_buf_num + 1) & OETH_TXBD_NUM_MASK;
386
 
387
  return;
388
 
389
 
390
}
391
 
392
/* The interrupt handler.
393
*/
394
void
395
oeth_interrupt(void)
396
{
397
 
398
  volatile oeth_regs *regs;
399
  regs = (oeth_regs *)(OETH_REG_BASE);
400
 
401
  uint  int_events;
402
  int serviced;
403
 
404
  serviced = 0;
405
 
406
  /* Get the interrupt events that caused us to be here.
407
  */
408
  int_events = regs->int_src;
409
  regs->int_src = int_events;
410
 
411
  /* Handle receive event in its own function.
412
  */
413
  if (int_events & (OETH_INT_RXF | OETH_INT_RXE)) {
414
    serviced |= 0x1;
415
    oeth_rx();
416
  }
417
 
418
  /* Handle transmit event in its own function.
419
  */
420
  if (int_events & (OETH_INT_TXB | OETH_INT_TXE)) {
421
    serviced |= 0x2;
422
    oeth_tx();
423
    serviced |= 0x2;
424
 
425
  }
426
 
427
  /* Check for receive busy, i.e. packets coming but no place to
428
  * put them.
429
  */
430
  if (int_events & OETH_INT_BUSY) {
431
    serviced |= 0x4;
432
    if (!(int_events & (OETH_INT_RXF | OETH_INT_RXE)))
433
      oeth_rx();
434
  }
435
 
436
  return;
437
}
438
 
439
 
440
 
441
static void
442
oeth_rx(void)
443
{
444
  volatile oeth_regs *regs;
445
  regs = (oeth_regs *)(OETH_REG_BASE);
446
 
447
  volatile oeth_bd *rx_bdp;
448
  int   pkt_len, i;
449
  int   bad = 0;
450
 
451
  rx_bdp = ((oeth_bd *)OETH_BD_BASE) + OETH_TXBD_NUM;
452
 
453
 
454
  /* Find RX buffers marked as having received data */
455
  for(i = 0; i < OETH_RXBD_NUM; i++)
456
    {
457
      bad=0;
458
      if(!(rx_bdp[i].len_status & OETH_RX_BD_EMPTY)){ /* Looking for NOT empty buffers desc. */
459
        /* Check status for errors.
460
        */
461
        if (rx_bdp[i].len_status & (OETH_RX_BD_TOOLONG | OETH_RX_BD_SHORT)) {
462
          bad = 1;
463
          report(0xbaad0001);
464
        }
465
        if (rx_bdp[i].len_status & OETH_RX_BD_DRIBBLE) {
466
          bad = 1;
467
          report(0xbaad0002);
468
        }
469
        if (rx_bdp[i].len_status & OETH_RX_BD_CRCERR) {
470
          bad = 1;
471
          report(0xbaad0003);
472
        }
473
        if (rx_bdp[i].len_status & OETH_RX_BD_OVERRUN) {
474
          bad = 1;
475
          report(0xbaad0004);
476
        }
477
        if (rx_bdp[i].len_status & OETH_RX_BD_MISS) {
478 530 julius
                // not necessarily an issue
479 411 julius
          report(0xbaad0005);
480
        }
481
        if (rx_bdp[i].len_status & OETH_RX_BD_LATECOL) {
482
          bad = 1;
483
          report(0xbaad0006);
484
        }
485
        if (bad) {
486
          rx_bdp[i].len_status &= ~OETH_RX_BD_STATS;
487
          rx_bdp[i].len_status |= OETH_RX_BD_EMPTY;
488
          exit(0xbaaaaaad);
489
 
490
          continue;
491
        }
492
        else {
493
          /* Process the incoming frame.
494
          */
495
          pkt_len = rx_bdp[i].len_status >> 16;
496
 
497
          /* finish up */
498
          rx_bdp[i].len_status &= ~OETH_RX_BD_STATS; /* Clear stats */
499
          rx_bdp[i].len_status |= OETH_RX_BD_EMPTY; /* Mark RX BD as empty */
500
          rx_done++;
501
        }
502
      }
503
    }
504
}
505
 
506
 
507
 
508
static void
509
oeth_tx(void)
510
{
511
  volatile oeth_bd *tx_bd;
512
  int i;
513
 
514
  tx_bd = (volatile oeth_bd *)OETH_BD_BASE; /* Search from beginning*/
515
 
516
  /* Go through the TX buffs, search for one that was just sent */
517
  for(i = 0; i < OETH_TXBD_NUM; i++)
518
    {
519
      /* Looking for buffer NOT ready for transmit. and IRQ enabled */
520
      if( (!(tx_bd[i].len_status & (OETH_TX_BD_READY))) && (tx_bd[i].len_status & (OETH_TX_BD_IRQ)) )
521
        {
522
          /* Single threaded so no chance we have detected a buffer that has had its IRQ bit set but not its BD_READ flag. Maybe this won't work in linux */
523
          tx_bd[i].len_status &= ~OETH_TX_BD_IRQ;
524
 
525
          /* Probably good to check for TX errors here */
526
 
527
          /* set our test variable */
528
          tx_done++;
529
 
530
        }
531
    }
532
  return;
533
}
534
 
535
// A function and defines to fill and transmit a packet
536
#define MAX_TX_BUFFER 1532
537
static char tx_buffer[MAX_TX_BUFFER];
538
 
539
void
540
fill_and_tx_call_packet(int size, int response_time)
541
{
542
  int i;
543
 
544
  volatile oeth_regs *regs;
545
  regs = (oeth_regs *)(OETH_REG_BASE);
546
 
547
  volatile oeth_bd *tx_bd;
548
 
549
  tx_bd = (volatile oeth_bd *)OETH_BD_BASE;
550
  tx_bd = (volatile oeth_bd*) &tx_bd[next_tx_buf_num];
551
 
552
  // If it's in use - wait
553
  while ((tx_bd->len_status & OETH_TX_BD_IRQ));
554
 
555
  // Use rand() function to generate data for transmission
556
  // Assumption: ethernet buffer descriptors are 4byte aligned
557
  char* data_b = (char*) tx_bd->addr;
558
  // We will fill with words until there' less than a word to go
559
  int words_to_fill = size / sizeof(unsigned int);
560
 
561
  unsigned int* data_w = (unsigned int*) data_b;
562
 
563
  // Put first word as size of packet, second as response time
564
  data_w[0] = size;
565
  data_w[1] = response_time;
566
 
567
  for(i=2;i<words_to_fill;i++)
568
    data_w[i] = rand();
569
 
570
  // Point data_b to offset wher word fills ended
571
  data_b += (words_to_fill * sizeof(unsigned int));
572
 
573
  int leftover_size = size - (words_to_fill * sizeof(unsigned int));
574
 
575
  for(i=0;i<leftover_size;i++)
576
    {
577
      data_b[i] = rand() & 0xff;
578
    }
579
 
580
  tx_packet((void*)0, size);
581
}
582
 
583
// Send a packet, the very first byte of which will be read by the testbench
584
// and used to indicate which test we'll use.
585
void
586
send_ethmac_rxtx_test_init_packet(char test)
587
{
588
  char cmd_tx_buffer[40];
589
  cmd_tx_buffer[0] = test;
590
  tx_packet(cmd_tx_buffer,  40); // Smallest packet that can be sent (I think)
591
}
592
 
593
// Loop to check if a number is prime by doing mod divide of the number
594
// to test by every number less than it
595
int
596
is_prime_number(unsigned long n)
597
{
598
  unsigned long c;
599
  if (n < 2) return 0;
600
  for(c=2;c<n;c++)
601
    if ((n % c) == 0)
602
      return 0;
603
  return 1;
604
}
605
 
606
 
607
int
608
main ()
609
{
610
  tx_data_pointer = 0;
611
 
612
  /* Initialise handler vector */
613
  int_init();
614
 
615
  /* Install ethernet interrupt handler, it is enabled here too */
616
  int_add(ETH0_IRQ, oeth_interrupt, 0);
617
 
618
  /* Enable interrupts in supervisor register */
619
  cpu_enable_user_interrupts();
620
 
621
  /* Enable CPU timer */
622
  cpu_enable_timer();
623
 
624
  ethmac_setup(); /* Configure MAC, TX/RX BDs and enable RX and TX in MODER */
625
 
626
  /* clear tx_done, the tx interrupt handler will set it when it's been
627
     transmitted */
628
  tx_done = 0;
629
  rx_done = 0;
630
 
631
  ethphy_set_100mbit(0);
632
 
633
  send_ethmac_rxtx_test_init_packet(0x0); // 0x0 - call response test
634
 
635
#define ETH_TX_MIN_PACKET_SIZE 512
636 530 julius
#define ETH_TX_NUM_PACKETS  20
637 411 julius
 
638
  //int response_time = 150000; // Response time before response packet it sent
639
                              // back (should be in nanoseconds).
640
  int response_time  = 0;
641
 
642
  unsigned long num_to_check;
643
  for(num_to_check=ETH_TX_MIN_PACKET_SIZE;
644 530 julius
      num_to_check<ETH_TX_MIN_PACKET_SIZE + ETH_TX_NUM_PACKETS;
645 411 julius
      num_to_check++)
646
    fill_and_tx_call_packet(num_to_check, response_time);
647
 
648
 
649
  // Wait a moment for the RX packet check to complete before switching off RX
650
  for(num_to_check=0;num_to_check=1000;num_to_check++);
651
 
652
  oeth_disable_rx();
653
 
654
  // Now for 10mbit mode...
655
  ethphy_set_10mbit(0);
656
 
657
  oeth_enable_rx();
658
 
659
  for(num_to_check=ETH_TX_MIN_PACKET_SIZE;
660 530 julius
      num_to_check<ETH_TX_MIN_PACKET_SIZE + ETH_TX_NUM_PACKETS;
661 411 julius
      num_to_check++)
662
    fill_and_tx_call_packet(num_to_check, response_time);
663
 
664
  oeth_disable_rx();
665
 
666
  // Go back to 100-mbit mode
667
  ethphy_set_100mbit(0);
668
 
669
  oeth_enable_rx();
670
 
671
  for(num_to_check=ETH_TX_MIN_PACKET_SIZE;
672
      num_to_check<ETH_TX_NUM_PACKETS;
673
      num_to_check++)
674
    fill_and_tx_call_packet(num_to_check, response_time);
675
 
676
  exit(0x8000000d);
677
 
678
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.