This source file includes following definitions.
- arcnet_probe
- arcnet_ioprobe
- arcnet_memprobe
- arcnet_open
- arcnet_close
- arcnet_send_packet
- careful_xmit_wait
- arcnet_tx
- arcnet_interrupt
- arcnet_inthandler
- arcnet_rx
- arcnet_timer
- arcnet_get_stats
- set_multicast_list
- arcnet_reset
- arc_header
- arc_rebuild_header
- arc_type_trans
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 #define CAREFUL_XMIT
45
46
47
48
49 #define STRICT_MEM_DETECT
50
51
52
53
54
55
56
57 #undef LIMIT_MTU
58
59
60
61
62
63
64
65
66
67
68 #undef USE_TIMER_HANDLER
69
70
71
72 static char *version =
73 "arcnet.c:v0.32 ALPHA 94/12/26 Avery Pennarun <apenwarr@tourism.807-city.on.ca>\n";
74
75
76
77 #include <linux/config.h>
78
79
80
81
82
83
84
85
86
87
88
89
90
91 #include <linux/kernel.h>
92 #include <linux/sched.h>
93 #include <linux/types.h>
94 #include <linux/fcntl.h>
95 #include <linux/interrupt.h>
96 #include <linux/ptrace.h>
97 #include <linux/ioport.h>
98 #include <linux/in.h>
99 #include <linux/malloc.h>
100 #include <linux/string.h>
101 #include <linux/timer.h>
102 #include <linux/errno.h>
103
104 #include <asm/system.h>
105 #include <asm/bitops.h>
106 #include <asm/io.h>
107 #include <asm/dma.h>
108
109 #include <linux/netdevice.h>
110 #include <linux/etherdevice.h>
111 #include <linux/skbuff.h>
112 #include "arp.h"
113
114
115
116
117
118
119
120
121
122 #define D_OFF 0
123 #define D_NORMAL 1
124 #define D_INIT 2
125 #define D_EXTRA 3
126 #define D_DURING 4
127 #define D_TX 5
128 #define D_RX 6
129
130 #ifndef NET_DEBUG
131 #define NET_DEBUG D_INIT
132 #endif
133 static unsigned int net_debug = NET_DEBUG;
134
135 #ifndef HAVE_AUTOIRQ
136
137 extern void autoirq_setup(int waittime);
138 extern int autoirq_report(int waittime);
139
140
141 extern struct device *irq2dev_map[16];
142 #endif
143
144 #ifndef HAVE_PORTRESERVE
145 #define check_region(ioaddr, size) 0
146 #define snarf_region(ioaddr, size); do ; while (0)
147 #endif
148
149
150 #define BUGLVL(x) if (net_debug>=x)
151
152
153 #define ETHERCARD_TOTAL_SIZE 16
154
155
156
157
158 #define INTMASK (ioaddr+0)
159 #define STATUS (ioaddr+0)
160 #define COMMAND (ioaddr+1)
161 #define RESET (ioaddr+8)
162
163
164 #define RESETtime 40
165 #define XMITtime 10
166 #define ACKtime 10
167
168
169
170
171
172
173
174
175
176 #define MTU (253+EXTRA_CLIENTDATA)
177 #define MinTU (257+EXTRA_CLIENTDATA)
178 #define XMTU (508+EXTRA_CLIENTDATA)
179
180
181 #define TXFREEflag 0x001
182 #define TXACKflag 0x002
183 #define RECONflag 0x004
184 #define TESTflag 0x008
185 #define RESETflag 0x010
186 #define RES1flag 0x020
187 #define RES2flag 0x040
188 #define NORXflag 0x080
189
190
191
192
193
194
195 #define NOTXcmd 0x001
196 #define NORXcmd 0x002
197 #define TXcmd 0x003
198 #define RXcmd 0x004
199 #define CONFIGcmd 0x005
200 #define CFLAGScmd 0x006
201 #define TESTcmd 0x007
202
203
204 #define RESETclear 0x008
205 #define CONFIGclear 0x010
206
207
208 #define TESTload 0x008
209
210
211 #define TESTvalue 0321
212
213
214 #define RXbcasts 0x080
215
216
217 #define NORMALconf 0x000
218 #define EXTconf 0x008
219
220
221
222 #define EnableReceiver() outb(RXcmd|(recbuf<<3)|RXbcasts,COMMAND)
223 #define TXbuf 2
224
225
226 #define ARC_P_IP 212
227 #define ARC_P_ARP 213
228 #define ARC_P_RARP 214
229
230
231 #define TIMERval (HZ/8)
232
233
234 #define NORMAL 0
235 #define EXTENDED 1
236 #define EXCEPTION 2
237
238
239 struct HardHeader
240 {
241 u_char source,
242 destination,
243 offset1,
244 offset2;
245 };
246
247
248 union ArcPacket
249 {
250 struct HardHeader hardheader;
251 u_char raw[512];
252 };
253
254
255
256
257
258 struct ClientData
259 {
260
261 u_char daddr;
262
263
264
265 u_char stupid;
266
267
268 u_char protocol_id,
269 split_flag;
270 u_short sequence;
271 };
272 #define EXTRA_CLIENTDATA (sizeof(struct ClientData)-4)
273
274
275
276
277
278 struct Incoming
279 {
280 struct sk_buff *skb;
281 unsigned char lastpacket,
282 numpackets;
283 u_short sequence;
284 };
285
286
287
288 struct arcnet_local {
289 struct enet_statistics stats;
290 u_char arcnum;
291 u_short sequence;
292 u_char recbuf;
293 int intx;
294 struct timer_list timer;
295 struct Incoming incoming[256];
296 };
297
298
299
300
301 extern int arcnet_probe(struct device *dev);
302 static int arcnet_memprobe(struct device *dev,u_char *addr);
303 static int arcnet_ioprobe(struct device *dev, short ioaddr);
304
305 static int arcnet_open(struct device *dev);
306 static int arcnet_close(struct device *dev);
307
308 static int arcnet_send_packet(struct sk_buff *skb, struct device *dev);
309 static void careful_xmit_wait(struct device *dev);
310 static int arcnet_tx(struct device *dev,struct ClientData *hdr,short length,
311 char *data);
312
313 static void arcnet_interrupt(int irq, struct pt_regs *regs);
314 static void arcnet_inthandler(struct device *dev);
315 static void arcnet_rx(struct device *dev,int recbuf);
316
317
318 static void arcnet_timer(unsigned long arg);
319
320 static struct enet_statistics *arcnet_get_stats(struct device *dev);
321 static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
322
323
324 int arc_header(unsigned char *buff,struct device *dev,unsigned short type,
325 void *daddr,void *saddr,unsigned len,struct sk_buff *skb);
326 int arc_rebuild_header(void *eth,struct device *dev,unsigned long raddr,
327 struct sk_buff *skb);
328 unsigned short arc_type_trans(struct sk_buff *skb,struct device *dev);
329
330
331 #define tx_done(dev) 1
332 #define JIFFER(time) for (delayval=jiffies+(time); delayval>=jiffies;);
333 static int arcnet_reset(struct device *dev);
334
335
336
337
338
339
340
341
342 int
343 arcnet_probe(struct device *dev)
344 {
345
346
347
348 int *port, ports[] = {
349 0x300,0x2E0,0x2F0,0x2D0,
350
351 0x200,0x210,0x220,0x230,0x240,0x250,0x260,0x270,
352 0x280,0x290,0x2a0,0x2b0,0x2c0,
353 0x310,0x320,0x330,0x340,0x350,0x360,0x370,
354 0x380,0x390,0x3a0,0x3b0,0x3c0,0x3d0,0x3e0,0x3f0,
355
356 0};
357
358
359 unsigned long *addr, addrs[] = {0xD0000,0xE0000,0xA0000,0xB0000,
360 0xC0000,0xF0000,
361
362 0xE1000,
363 0xDD000,0xDC000,
364 0xD9000,0xD8000,0xD5000,0xD4000,0xD1000,
365 0xCD000,0xCC000,
366 0xC9000,0xC8000,0xC5000,0xC4000,
367
368 0};
369 int base_addr=dev->base_addr, status=0,delayval;
370 struct arcnet_local *lp;
371
372 if (net_debug) printk(version);
373
374 BUGLVL(D_INIT)
375 printk("arcnet: given: base %Xh, IRQ %Xh, shmem %lXh\n",
376 dev->base_addr,dev->irq,dev->mem_start);
377
378 if (base_addr > 0x1ff)
379 status=arcnet_ioprobe(dev, base_addr);
380 else if (base_addr > 0)
381 return ENXIO;
382 else for (port = &ports[0]; *port; port++)
383 {
384 int ioaddr = *port;
385 if (check_region(ioaddr, ETHERCARD_TOTAL_SIZE))
386 {
387 BUGLVL(D_INIT)
388 printk("arcnet: Skipping %Xh because of check_region...\n",
389 ioaddr);
390 continue;
391 }
392
393 status=arcnet_ioprobe(dev, ioaddr);
394 if (!status) break;
395 }
396
397 if (status) return status;
398
399
400
401
402 BUGLVL(D_INIT)
403 printk("arcnet: ioprobe okay! Waiting for reset...\n");
404 JIFFER(100);
405
406
407 BUGLVL(D_INIT)
408 printk("arcnet: starting memory probe, given %lXh\n",
409 dev->mem_start);
410 if (dev->mem_start)
411 {
412 status=arcnet_memprobe(dev,(u_char *)dev->mem_start);
413 if (status) return status;
414 }
415 else
416 {
417 for (addr = &addrs[0]; *addr; addr++) {
418 status=arcnet_memprobe(dev,(u_char *)(*addr));
419 if (!status) break;
420 }
421
422 if (status) return status;
423 }
424
425
426 { int irqval = request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet");
427 if (irqval) {
428 printk("%s: unable to get IRQ %d (irqval=%d).\n", dev->name,
429 dev->irq, irqval);
430 return EAGAIN;
431 }
432 }
433
434
435 snarf_region(dev->base_addr, ETHERCARD_TOTAL_SIZE);
436
437 printk("%s: ARCnet card found at %03Xh, IRQ %d, ShMem at %lXh.\n", dev->name,
438 dev->base_addr, dev->irq, dev->mem_start);
439
440
441 dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
442 memset(dev->priv, 0, sizeof(struct arcnet_local));
443 lp=(struct arcnet_local *)(dev->priv);
444
445 dev->open = arcnet_open;
446 dev->stop = arcnet_close;
447 dev->hard_start_xmit = arcnet_send_packet;
448 dev->get_stats = arcnet_get_stats;
449 #ifdef HAVE_MULTICAST
450 dev->set_multicast_list = &set_multicast_list;
451 #endif
452
453
454 ether_setup(dev);
455
456
457
458 dev->type=ARPHRD_ARCNET;
459 dev->hard_header_len=sizeof(struct ClientData);
460 BUGLVL(D_EXTRA)
461 printk("arcnet: ClientData header size is %d.\narcnet: HardHeader size is %d.\n",
462 sizeof(struct ClientData),sizeof(struct HardHeader));
463 #if LIMIT_MTU
464 dev->mtu=512-sizeof(struct HardHeader)+EXTRA_CLIENTDATA;
465 #endif
466
467
468
469 dev->addr_len=1;
470 dev->broadcast[0]=0x00;
471
472 BUGLVL(D_INIT) printk("arcnet: arcnet_probe: resetting card.\n");
473 arcnet_reset(dev);
474 JIFFER(50);
475 BUGLVL(D_NORMAL)
476 printk("arcnet: We appear to be station %d (%02Xh)\n",
477 lp->arcnum,lp->arcnum);
478 if (lp->arcnum==0)
479 printk("arcnet: WARNING! Station address 0 is reserved for broadcasts!\n");
480 if (lp->arcnum==255)
481 printk("arcnet: WARNING! Station address 255 may confuse DOS networking programs!\n");
482 dev->dev_addr[0]=lp->arcnum;
483 lp->sequence=1;
484 lp->recbuf=0;
485
486 dev->hard_header = arc_header;
487
488 dev->rebuild_header = arc_rebuild_header;
489 dev->type_trans = arc_type_trans;
490
491 return 0;
492 }
493
494 int arcnet_ioprobe(struct device *dev, short ioaddr)
495 {
496 int delayval,airq;
497
498 BUGLVL(D_INIT)
499 printk("arcnet: probing address %Xh\n",ioaddr);
500
501 BUGLVL(D_INIT)
502 printk("arcnet: status1=%Xh\n",inb(STATUS));
503
504
505
506
507
508
509
510
511 inb(RESET);
512 JIFFER(RESETtime);
513
514
515 if (inb(STATUS)==0xFF)
516 {
517 BUGLVL(D_INIT)
518 printk("arcnet: probe failed. Status port empty.\n");
519 return ENODEV;
520 }
521
522
523
524
525
526
527 {
528 int initval,curval;
529
530 curval=initval=inb(COMMAND);
531 delayval=jiffies+5;
532 while (delayval>=jiffies && curval==initval)
533 curval=inb(COMMAND);
534
535 if (curval==initval)
536 {
537 printk("arcnet: probe failed. never-changing command port (%02Xh).\n",
538 initval);
539 return ENODEV;
540 }
541 }
542
543 BUGLVL(D_INIT)
544 printk("arcnet: status2=%Xh\n",inb(STATUS));
545
546
547 outb(CFLAGScmd|RESETclear|CONFIGclear,COMMAND);
548 JIFFER(ACKtime);
549 if (inb(STATUS) & RESETflag)
550 {
551 BUGLVL(D_INIT)
552 printk("arcnet: probe failed. eternal reset flag1...(status=%Xh)\n",
553 inb(STATUS));
554 return ENODEV;
555 }
556
557
558 autoirq_setup(0);
559
560
561 outb(RESETflag,INTMASK);
562
563
564 inb(RESET);
565 JIFFER(RESETtime);
566
567 BUGLVL(D_INIT)
568 printk("arcnet: status3=%Xh\n",inb(STATUS));
569
570
571 outb(RESETflag,INTMASK);
572
573
574 outb(CFLAGScmd|RESETclear|CONFIGclear,COMMAND);
575 JIFFER(ACKtime);
576
577 BUGLVL(D_INIT)
578 printk("arcnet: status4=%Xh\n",inb(STATUS));
579
580
581 inb(RESET);
582 JIFFER(RESETtime);
583
584 BUGLVL(D_INIT)
585 printk("arcnet: status5=%Xh\n",inb(STATUS));
586
587 airq = autoirq_report(0);
588 if (net_debug>=D_INIT && airq)
589 printk("arcnet: autoirq is %d\n", airq);
590
591
592
593
594 if (!airq && !(dev->base_addr && dev->irq))
595 {
596 BUGLVL(D_INIT)
597 printk("arcnet: probe failed. no autoirq...\n");
598 return ENODEV;
599 }
600
601
602
603 if (inb(STATUS) & RESETflag)
604 {
605
606 outb(CFLAGScmd|RESETclear|CONFIGclear,COMMAND);
607 JIFFER(ACKtime);
608 }
609
610 if (inb(STATUS) & RESETflag)
611 {
612 BUGLVL(D_INIT)
613 printk("arcnet: probe failed. eternal reset flag...(status=%Xh)\n",
614 inb(STATUS));
615 return ENODEV;
616 }
617
618
619 if (!dev->base_addr) dev->base_addr=ioaddr;
620
621 if (dev->irq < 2)
622 {
623
624 dev->irq=airq;
625 }
626 else if (dev->irq == 2)
627 {
628 if (net_debug)
629 printk("arcnet: IRQ2 == IRQ9, don't worry.\n");
630 dev->irq = 9;
631 }
632
633 BUGLVL(D_INIT)
634 printk("arcnet: irq and base address seem okay. (%Xh, IRQ %d)\n",
635 dev->base_addr,dev->irq);
636 return 0;
637 }
638
639
640
641
642
643 int arcnet_memprobe(struct device *dev,u_char *addr)
644 {
645 BUGLVL(D_INIT)
646 printk("arcnet: probing memory at %lXh\n",(u_long)addr);
647
648 dev->mem_start=0;
649
650 #ifdef STRICT_MEM_DETECT
651
652 if (addr[0]!=TESTvalue)
653 {
654 BUGLVL(D_INIT)
655 printk("arcnet: probe failed. addr=%lXh, addr[0]=%Xh (not %Xh)\n",
656 (unsigned long)addr,addr[0],TESTvalue);
657 return ENODEV;
658 }
659
660
661 addr[0]=0x42;
662 if (addr[0]!=0x42)
663 {
664 BUGLVL(D_INIT)
665 printk("arcnet: probe failed. addr=%lXh, addr[0]=%Xh (not 42h)\n",
666 (unsigned long)addr,addr[0]);
667 return ENODEV;
668 }
669 #else
670 if (addr[0]!=TESTvalue)
671 {
672 BUGLVL(D_INIT)
673 printk("arcnet: probe failed. addr=%lXh, addr[0]=%Xh (not %Xh)\n",
674 (unsigned long)addr,addr[0],TESTvalue);
675 return ENODEV;
676 }
677 #endif
678
679
680 dev->mem_start=(unsigned long)addr;
681 dev->mem_end=dev->mem_start+512*4-1;
682 dev->rmem_start=dev->mem_start+512*0;
683 dev->rmem_end=dev->mem_start+512*2-1;
684
685 return 0;
686 }
687
688
689
690
691
692
693
694
695
696 static int
697 arcnet_open(struct device *dev)
698 {
699 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
700
701
702 if (net_debug) printk(version);
703
704 #if 0
705
706
707 if (request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet")) {
708 return -EAGAIN;
709 }
710 #endif
711
712 irq2dev_map[dev->irq] = dev;
713
714
715 BUGLVL(D_EXTRA) printk("arcnet: arcnet_open: resetting card.\n");
716 if (arcnet_reset(dev)) return -ENODEV;
717
718
719
720
721
722
723 dev->tbusy = 0;
724 dev->interrupt = 0;
725 dev->start = 1;
726
727
728 init_timer(&lp->timer);
729 lp->timer.expires = TIMERval;
730 lp->timer.data = (unsigned long)dev;
731 lp->timer.function = &arcnet_timer;
732 #ifdef USE_TIMER_HANDLER
733 add_timer(&lp->timer);
734 #endif
735
736 return 0;
737 }
738
739
740
741 static int
742 arcnet_close(struct device *dev)
743 {
744 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
745 int ioaddr = dev->base_addr, delayval;
746
747
748
749 dev->tbusy = 1;
750 dev->start = 0;
751
752
753 del_timer(&lp->timer);
754
755
756
757
758
759 outb(0,INTMASK);
760 outb(NOTXcmd,COMMAND);
761 JIFFER(ACKtime);
762 outb(NORXcmd,COMMAND);
763
764 #if 0
765
766 outw(0x00, ioaddr+0);
767 free_irq(dev->irq);
768 irq2dev_map[dev->irq] = 0;
769 #endif
770
771
772
773 return 0;
774 }
775
776
777 static int
778 arcnet_send_packet(struct sk_buff *skb, struct device *dev)
779 {
780 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
781 int ioaddr=dev->base_addr,stat=0;
782
783
784 lp->intx++;
785
786 BUGLVL(D_DURING)
787 printk("arcnet: transmit requested (status=%Xh, inTX=%d)\n",
788 inb(STATUS),lp->intx);
789
790 if (dev->tbusy)
791 {
792
793
794 int tickssofar = jiffies - dev->trans_start;
795 int recbuf=lp->recbuf;
796 int status=inb(STATUS);
797
798 if (tickssofar < 5) return 1;
799
800 BUGLVL(D_INIT)
801 printk("arcnet: transmit timed out (status=%Xh, inTX=%d, tickssofar=%d)\n",
802 status,lp->intx,tickssofar);
803
804
805
806
807 if (status&NORXflag) EnableReceiver();
808 if (!(status&TXFREEflag)) outb(NOTXcmd,COMMAND);
809 dev->tbusy=0;
810 mark_bh(NET_BH);
811 dev->trans_start = jiffies;
812 lp->intx--;
813 return 1;
814 }
815
816
817
818
819 if (skb == NULL) {
820 BUGLVL(D_INIT)
821 printk("arcnet: tx passed null skb (status=%Xh, inTX=%d, tickssofar=%ld)\n",
822 inb(STATUS),lp->intx,jiffies-dev->trans_start);
823 dev_tint(dev);
824 lp->intx--;
825 return 0;
826 }
827
828
829
830 if (set_bit(0, (void*)&dev->tbusy) != 0)
831 {
832 printk("arcnet: Transmitter called with busy bit set! (status=%Xh, inTX=%d, tickssofar=%ld)\n",
833 inb(STATUS),lp->intx,jiffies-dev->trans_start);
834 stat=-EBUSY;
835 }
836 else {
837 short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
838 struct ClientData *hdr=(struct ClientData*)skb->data;
839
840 if (length<=XMTU)
841 {
842 BUGLVL(D_TX) printk("arcnet: not splitting %d-byte packet. (split_flag=%d)\n",
843 length,hdr->split_flag);
844 BUGLVL(D_INIT) if (hdr->split_flag)
845 printk("arcnet: short packet has split_flag set?! (split_flag=%d)\n",
846 hdr->split_flag);
847 stat=arcnet_tx(dev,hdr,
848 length-sizeof(struct ClientData),
849 ((char *)skb->data)+sizeof(struct ClientData));
850 }
851 else
852 {
853 u_char *data=(u_char *)skb->data
854 + sizeof(struct ClientData);
855 int dataleft=length-sizeof(struct ClientData),
856 maxsegsize=XMTU-sizeof(struct ClientData),
857 numsegs=(dataleft+maxsegsize-1)/maxsegsize,
858 seglen,segnum=0;
859
860 BUGLVL(D_TX) printk("arcnet: packet (%d bytes) split into %d fragments:\n",
861 length,numsegs);
862
863 while (!stat && dataleft)
864 {
865 if (!segnum)
866 hdr->split_flag=((numsegs-2)<<1)+1;
867 else
868 hdr->split_flag=segnum<<1;
869
870 seglen=maxsegsize;
871 if (seglen>dataleft) seglen=dataleft;
872
873 BUGLVL(D_TX) printk("arcnet: packet #%d (%d bytes) of %d (%d total), splitflag=%d\n",
874 segnum+1,seglen,numsegs,length,hdr->split_flag);
875
876 stat=arcnet_tx(dev,hdr,seglen,data);
877
878 dataleft-=seglen;
879 data+=seglen;
880 segnum++;
881
882 #if 0
883
884 hdr->sequence++;
885 lp->sequence++;
886 #endif
887 }
888 }
889
890
891
892
893
894 if (!stat) dev_kfree_skb(skb, FREE_WRITE);
895
896
897 if (stat!=-EBUSY)
898 {
899 dev->tbusy=0;
900 mark_bh(NET_BH);
901
902
903
904 }
905 }
906
907 lp->intx--;
908
909 if (!stat) lp->stats.tx_packets++;
910 return stat;
911 }
912
913 #ifdef CAREFUL_XMIT
914 static void careful_xmit_wait(struct device *dev)
915 {
916 int ioaddr=dev->base_addr;
917 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
918
919
920 while ( !(inb(STATUS)&TXFREEflag) )
921 {
922 if (jiffies-dev->trans_start > 20 || !dev->tbusy)
923 {
924 BUGLVL(D_INIT)
925 printk("arcnet: CAREFUL_XMIT timeout. (busy=%d, status=%Xh)\n",
926 dev->tbusy,inb(STATUS));
927 lp->stats.tx_errors++;
928
929 outb(NOTXcmd,COMMAND);
930 return;
931 }
932 }
933 BUGLVL(D_TX) printk("arcnet: transmit completed successfully. (status=%Xh)\n",
934 inb(STATUS));
935 }
936 #endif
937
938 static int
939 arcnet_tx(struct device *dev,struct ClientData *hdr,short length,
940 char *data)
941 {
942 int ioaddr = dev->base_addr;
943 #if 0
944 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
945 #endif
946 struct ClientData *arcsoft;
947 union ArcPacket *arcpacket =
948 (union ArcPacket *)(dev->mem_start+512*TXbuf);
949 u_char pkttype;
950 int offset;
951 short daddr;
952
953 length+=sizeof(struct ClientData);
954
955 BUGLVL(D_TX)
956 printk("arcnet: arcnet_tx: hdr:%ph, length:%d, data:%ph\n",
957 hdr,length,data);
958
959 #if 0
960
961 if (! (inb(STATUS) & TXFREEflag))
962 {
963 BUGLVL(D_TX)
964 printk("arcnet: transmitter in use! (status=%Xh)\n",
965 inb(STATUS));
966 return -EBUSY;
967 }
968 #endif
969
970
971
972
973
974 #ifdef CAREFUL_XMIT
975 careful_xmit_wait(dev);
976 #endif
977
978
979 BUGLVL(D_DURING)
980 memset((void *)dev->mem_start+TXbuf*512,0x42,512);
981
982 daddr=arcpacket->hardheader.destination=hdr->daddr;
983
984
985 if (length<=MTU)
986 {
987 pkttype=NORMAL;
988
989 arcpacket->hardheader.offset1=offset=256-length
990 + EXTRA_CLIENTDATA;
991 arcsoft=(struct ClientData *)
992 (&arcpacket->raw[offset-EXTRA_CLIENTDATA]);
993 }
994 else if (length>=MinTU)
995 {
996 pkttype=EXTENDED;
997
998 arcpacket->hardheader.offset1=0;
999 arcpacket->hardheader.offset2=offset=512-length
1000 + EXTRA_CLIENTDATA;
1001 arcsoft=(struct ClientData *)
1002 (&arcpacket->raw[offset-EXTRA_CLIENTDATA]);
1003 }
1004 else
1005 {
1006 pkttype=EXCEPTION;
1007
1008 arcpacket->hardheader.offset1=0;
1009 arcpacket->hardheader.offset2=offset=512-length-4
1010 + EXTRA_CLIENTDATA;
1011 arcsoft=(struct ClientData *)
1012 (&arcpacket->raw[offset+4-EXTRA_CLIENTDATA]);
1013
1014
1015
1016
1017
1018 arcpacket->raw[offset+0]=arcsoft->protocol_id;
1019 arcpacket->raw[offset+1]=0xFF;
1020 arcpacket->raw[offset+2]=0xFF;
1021 arcpacket->raw[offset+3]=0xFF;
1022 }
1023
1024
1025
1026
1027
1028 memcpy((u_char*)arcsoft+EXTRA_CLIENTDATA,
1029 (u_char*)hdr+EXTRA_CLIENTDATA,
1030 sizeof(struct ClientData)-EXTRA_CLIENTDATA);
1031 memcpy((u_char*)arcsoft+sizeof(struct ClientData),
1032 data,
1033 length-sizeof(struct ClientData));
1034
1035 BUGLVL(D_DURING) printk("arcnet: transmitting packet to station %02Xh (%d bytes, type=%d)\n",
1036 daddr,length,pkttype);
1037
1038 BUGLVL(D_TX)
1039 {
1040 int countx,county;
1041
1042 printk("arcnet: packet dump [tx] follows:");
1043
1044 for (county=0; county<16+(pkttype!=NORMAL)*16; county++)
1045 {
1046 printk("\n[%04X] ",county*16);
1047 for (countx=0; countx<16; countx++)
1048 printk("%02X ",
1049 arcpacket->raw[county*16+countx]);
1050 }
1051
1052 printk("\n");
1053 }
1054
1055
1056
1057 outb(TXcmd|(TXbuf<<3),COMMAND);
1058
1059 dev->trans_start = jiffies;
1060
1061 BUGLVL(D_TX) printk("arcnet: transmit started successfully. (status=%Xh)\n",
1062 inb(STATUS));
1063 #ifdef CAREFUL_XMIT
1064 #if 0
1065 careful_xmit_wait(dev);
1066
1067
1068
1069
1070
1071 if (daddr && !(inb(STATUS)&TXACKflag))
1072 {
1073 BUGLVL(D_INIT)
1074 printk("arcnet: transmit not acknowledged. (status=%Xh, daddr=%02Xh)\n",
1075 inb(STATUS),daddr);
1076 lp->stats.tx_errors++;
1077 return -ENONET;
1078 }
1079 #endif
1080 #endif
1081
1082 return 0;
1083 }
1084
1085
1086
1087
1088 static void
1089 arcnet_interrupt(int irq, struct pt_regs *regs)
1090 {
1091 struct device *dev = (struct device *)(irq2dev_map[irq]);
1092
1093 if (dev == NULL) {
1094 if (net_debug >= D_DURING)
1095 printk("arcnet: irq %d for unknown device.\n", irq);
1096 return;
1097 }
1098
1099 arcnet_inthandler(dev);
1100 }
1101
1102 static void
1103 arcnet_inthandler(struct device *dev)
1104 {
1105 struct arcnet_local *lp;
1106 int ioaddr, status, boguscount = 20;
1107
1108 dev->interrupt = 1;
1109
1110 ioaddr = dev->base_addr;
1111 lp = (struct arcnet_local *)dev->priv;
1112
1113 BUGLVL(D_DURING)
1114 printk("arcnet: in net_interrupt (status=%Xh)\n",inb(STATUS));
1115
1116 do
1117 {
1118 status = inb(STATUS);
1119
1120 if (!dev->start)
1121 {
1122 BUGLVL(D_EXTRA)
1123 printk("arcnet: ARCnet not yet initialized. irq ignored. (status=%Xh)\n",
1124 inb(STATUS));
1125 break;
1126 }
1127
1128
1129
1130
1131 if (status & RESETflag)
1132 {
1133 BUGLVL(D_INIT)
1134 printk("arcnet: reset irq (status=%Xh)\n",
1135 status);
1136 break;
1137 }
1138
1139 #if 1
1140
1141 if (status & NORXflag)
1142 {
1143 int recbuf=lp->recbuf=!lp->recbuf;
1144
1145 BUGLVL(D_DURING)
1146 printk("arcnet: receive irq (status=%Xh)\n",
1147 status);
1148
1149
1150 EnableReceiver();
1151
1152
1153 arcnet_rx(dev,!recbuf);
1154 }
1155 #endif
1156
1157 #if 0
1158
1159
1160
1161 else if (dev->tbusy && status&TXFREEflag)
1162 {
1163 BUGLVL(D_DURING)
1164 printk("arcnet: transmit IRQ?!? (status=%Xh)\n",
1165 status);
1166
1167
1168 dev->tbusy = 0;
1169 mark_bh(NET_BH);
1170
1171 break;
1172 }
1173 else
1174 break;
1175 #endif
1176
1177 #if 0
1178 break;
1179 #endif
1180 } while (--boguscount);
1181
1182 BUGLVL(D_DURING)
1183 printk("arcnet: net_interrupt complete (status=%Xh)\n",
1184 inb(STATUS));
1185
1186 dev->interrupt=0;
1187 return;
1188 }
1189
1190
1191
1192 static void
1193 arcnet_rx(struct device *dev,int recbuf)
1194 {
1195 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
1196 int ioaddr = dev->base_addr;
1197
1198
1199 struct sk_buff *skb;
1200
1201 union ArcPacket *arcpacket=
1202 (union ArcPacket *)(dev->mem_start+recbuf*512);
1203 struct ClientData *soft,*arcsoft;
1204 short length,offset;
1205 u_char pkttype,daddr,saddr;
1206
1207 daddr=arcpacket->hardheader.destination;
1208 saddr=arcpacket->hardheader.source;
1209
1210
1211 if (saddr==0)
1212 {
1213
1214 printk("arcnet: discarding old packet. (status=%Xh)\n",
1215 inb(STATUS));
1216 lp->stats.rx_errors++;
1217 return;
1218 }
1219 arcpacket->hardheader.source=0;
1220
1221 if (arcpacket->hardheader.offset1)
1222 {
1223 offset=arcpacket->hardheader.offset1;
1224 arcsoft=(struct ClientData *)
1225 (&arcpacket->raw[offset-EXTRA_CLIENTDATA]);
1226 length=256-offset+EXTRA_CLIENTDATA;
1227 pkttype=NORMAL;
1228 }
1229 else
1230 {
1231 offset=arcpacket->hardheader.offset2;
1232 arcsoft=(struct ClientData *)
1233 (&arcpacket->raw[offset-EXTRA_CLIENTDATA]);
1234
1235 if (arcsoft->split_flag!=0xFF)
1236 {
1237 length=512-offset+EXTRA_CLIENTDATA;
1238 pkttype=EXTENDED;
1239 }
1240 else
1241 {
1242
1243 arcsoft=(struct ClientData *)
1244 ((u_char *)arcsoft + 4);
1245 length=512-offset+EXTRA_CLIENTDATA-4;
1246 pkttype=EXCEPTION;
1247 }
1248 }
1249
1250 if (!arcsoft->split_flag)
1251 {
1252 struct Incoming *in=&lp->incoming[saddr];
1253
1254 BUGLVL(D_RX) printk("arcnet: incoming is not split (splitflag=%d)\n",
1255 arcsoft->split_flag);
1256
1257 if (in->skb)
1258 {
1259 BUGLVL(D_INIT) printk("arcnet: aborting assembly (seq=%d) for unsplit packet (splitflag=%d, seq=%d)\n",
1260 in->sequence,arcsoft->split_flag,
1261 arcsoft->sequence);
1262 kfree_skb(in->skb,FREE_WRITE);
1263 in->skb=NULL;
1264 }
1265
1266 in->sequence=arcsoft->sequence;
1267
1268 skb = alloc_skb(length, GFP_ATOMIC);
1269 if (skb == NULL) {
1270 printk("%s: Memory squeeze, dropping packet.\n",
1271 dev->name);
1272 lp->stats.rx_dropped++;
1273 return;
1274 }
1275 soft=(struct ClientData *)skb->data;
1276
1277 skb->len = length;
1278 skb->dev = dev;
1279
1280 memcpy((u_char *)soft+EXTRA_CLIENTDATA,
1281 (u_char *)arcsoft+EXTRA_CLIENTDATA,
1282 length-EXTRA_CLIENTDATA);
1283 soft->daddr=daddr;
1284
1285 BUGLVL(D_DURING)
1286 printk("arcnet: received packet from %02Xh to %02Xh (%d bytes, type=%d)\n",
1287 saddr,daddr,length,pkttype);
1288 BUGLVL(D_RX)
1289 {
1290 int countx,county;
1291
1292 printk("arcnet: packet dump [rx-unsplit] follows:");
1293
1294 for (county=0; county<16+(pkttype!=NORMAL)*16; county++)
1295 {
1296 printk("\n[%04X] ",county*16);
1297 for (countx=0; countx<16; countx++)
1298 printk("%02X ",
1299 arcpacket->raw[county*16+countx]);
1300 }
1301
1302 printk("\n");
1303 }
1304
1305
1306
1307
1308
1309
1310 if (soft->protocol_id == ARC_P_ARP)
1311 {
1312 struct arphdr *arp=(struct arphdr *)
1313 ((char *)soft+sizeof(struct ClientData));
1314
1315
1316 if (arp->ar_hln==1 && arp->ar_pln==4)
1317 {
1318 char *cptr=(char *)(arp)+sizeof(struct arphdr);
1319
1320 if (!*cptr)
1321 {
1322 BUGLVL(D_DURING)
1323 printk("arcnet: ARP source address was 00h, set to %02Xh.\n",
1324 saddr);
1325 *cptr=saddr;
1326 }
1327 else BUGLVL(D_DURING)
1328 {
1329 printk("arcnet: ARP source address (%Xh) is fine.\n",
1330 *cptr);
1331 }
1332 }
1333 else
1334 {
1335 printk("arcnet: funny-shaped ARP packet. (%Xh, %Xh)\n",
1336 arp->ar_hln,arp->ar_pln);
1337 }
1338 }
1339
1340 netif_rx(skb);
1341 lp->stats.rx_packets++;
1342 }
1343 else
1344 {
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362 struct Incoming *in=&lp->incoming[saddr];
1363
1364 BUGLVL(D_RX) printk("arcnet: packet is split (splitflag=%d, seq=%d)\n",
1365 arcsoft->split_flag,in->sequence);
1366
1367 if (in->skb && in->sequence!=arcsoft->sequence)
1368 {
1369 BUGLVL(D_INIT) printk("arcnet: wrong seq number, aborting assembly (expected=%d, seq=%d, splitflag=%d)\n",
1370 in->sequence,arcsoft->sequence,
1371 arcsoft->split_flag);
1372 kfree_skb(in->skb,FREE_WRITE);
1373 in->skb=NULL;
1374 in->lastpacket=in->numpackets=0;
1375 return;
1376 }
1377
1378 if (arcsoft->split_flag & 1)
1379 {
1380 BUGLVL(D_RX) printk("arcnet: brand new splitpacket (splitflag=%d)\n",
1381 arcsoft->split_flag);
1382 if (in->skb)
1383 {
1384 BUGLVL(D_INIT) printk("arcnet: aborting previous (seq=%d) assembly (splitflag=%d, seq=%d)\n",
1385 in->sequence,arcsoft->split_flag,
1386 arcsoft->sequence);
1387 kfree_skb(in->skb,FREE_WRITE);
1388 }
1389
1390 in->sequence=arcsoft->sequence;
1391 in->numpackets=((unsigned)arcsoft->split_flag>>1)+2;
1392 in->lastpacket=1;
1393
1394 if (in->numpackets>16)
1395 {
1396 printk("arcnet: incoming packet more than 16 segments; dropping. (splitflag=%d)\n",
1397 arcsoft->split_flag);
1398 lp->stats.rx_dropped++;
1399 return;
1400 }
1401
1402 in->skb=skb=alloc_skb(508*in->numpackets
1403 + sizeof(struct ClientData),
1404 GFP_ATOMIC);
1405 if (skb == NULL) {
1406 printk("%s: (split) memory squeeze, dropping packet.\n",
1407 dev->name);
1408 lp->stats.rx_dropped++;
1409 return;
1410 }
1411
1412
1413
1414
1415 skb->free=1;
1416
1417 if (skb==NULL)
1418 {
1419 printk("%s: Memory squeeze, dropping packet.\n",
1420 dev->name);
1421 lp->stats.rx_dropped++;
1422 return;
1423 }
1424 soft=(struct ClientData *)skb->data;
1425
1426 skb->len=sizeof(struct ClientData);
1427 skb->dev=dev;
1428
1429 memcpy((u_char *)soft+EXTRA_CLIENTDATA,
1430 (u_char *)arcsoft+EXTRA_CLIENTDATA,
1431 sizeof(struct ClientData)-EXTRA_CLIENTDATA);
1432 soft->split_flag=0;
1433 }
1434 else
1435 {
1436 int packetnum=((unsigned)arcsoft->split_flag>>1) + 1;
1437
1438
1439
1440
1441 if (!in->skb)
1442 {
1443 BUGLVL(D_INIT) printk("arcnet: can't continue split without starting first! (splitflag=%d, seq=%d)\n",
1444 arcsoft->split_flag,arcsoft->sequence);
1445 return;
1446 }
1447
1448 in->lastpacket++;
1449 if (packetnum!=in->lastpacket)
1450 {
1451
1452 if (packetnum==in->lastpacket-1)
1453 {
1454 BUGLVL(D_INIT) printk("arcnet: duplicate splitpacket ignored! (splitflag=%d)\n",
1455 arcsoft->split_flag);
1456 return;
1457 }
1458
1459
1460 BUGLVL(D_INIT) printk("arcnet: out-of-order splitpacket, reassembly (seq=%d) aborted (splitflag=%d, seq=%d)\n",
1461 in->sequence,arcsoft->split_flag,
1462 arcsoft->sequence);
1463 kfree_skb(in->skb,FREE_WRITE);
1464 in->skb=NULL;
1465 in->lastpacket=in->numpackets=0;
1466 return;
1467 }
1468
1469 soft=(struct ClientData *)in->skb->data;
1470 }
1471
1472 skb=in->skb;
1473
1474 memcpy(skb->data+skb->len,
1475 (u_char *)arcsoft+sizeof(struct ClientData),
1476 length-sizeof(struct ClientData));
1477
1478 skb->len+=length-sizeof(struct ClientData);
1479
1480 soft->daddr=daddr;
1481
1482 BUGLVL(D_DURING)
1483 printk("arcnet: received packet from %02Xh to %02Xh (%d bytes, type=%d)\n",
1484 saddr,daddr,length,pkttype);
1485 BUGLVL(D_RX)
1486 {
1487 int countx,county;
1488
1489 printk("arcnet: packet dump [rx-split] follows:");
1490
1491 for (county=0; county<16+(pkttype!=NORMAL)*16; county++)
1492 {
1493 printk("\n[%04X] ",county*16);
1494 for (countx=0; countx<16; countx++)
1495 printk("%02X ",
1496 arcpacket->raw[county*16+countx]);
1497 }
1498
1499 printk("\n");
1500 }
1501
1502
1503 if (in->lastpacket == in->numpackets)
1504 {
1505 if (!skb || !in->skb)
1506 printk("arcnet: ?!? done reassembling packet, no skb? (skb=%ph, in->skb=%ph)\n",
1507 skb,in->skb);
1508 in->skb=NULL;
1509 in->lastpacket=in->numpackets=0;
1510 netif_rx(skb);
1511 lp->stats.rx_packets++;
1512 }
1513 }
1514
1515
1516
1517
1518
1519 }
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530 static void
1531 arcnet_timer(unsigned long arg)
1532 {
1533 struct device *dev=(struct device *)arg;
1534 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
1535 short ioaddr=dev->base_addr;
1536 int status=inb(STATUS);
1537
1538
1539
1540
1541 if (!dev->interrupt && dev->start
1542 && status&NORXflag && !status&RESETflag)
1543 {
1544 BUGLVL(D_INIT)
1545 printk("arcnet: timer: ARCnet was stuck! (status=%Xh)\n",
1546 status);
1547
1548 arcnet_inthandler(dev);
1549 }
1550
1551
1552 init_timer(&lp->timer);
1553 lp->timer.expires=TIMERval;
1554 add_timer(&lp->timer);
1555 }
1556
1557
1558
1559
1560 static struct enet_statistics *
1561 arcnet_get_stats(struct device *dev)
1562 {
1563 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
1564
1565
1566 return &lp->stats;
1567 }
1568
1569
1570
1571
1572
1573
1574
1575 static void
1576 set_multicast_list(struct device *dev, int num_addrs, void *addrs)
1577 {
1578 #if 0
1579 struct arcnet_local *lp=(struct arcnet_local *)(dev->priv);
1580
1581 short ioaddr = dev->base_addr;
1582 if (num_addrs) {
1583 outw(69, ioaddr);
1584 } else
1585 outw(99, ioaddr);
1586 #endif
1587 }
1588
1589 int arcnet_reset(struct device *dev)
1590 {
1591 struct arcnet_local *lp=(struct arcnet_local *)dev->priv;
1592 short ioaddr=dev->base_addr;
1593 int delayval,recbuf=lp->recbuf;
1594
1595 outb(0,INTMASK);
1596
1597 BUGLVL(D_INIT)
1598 printk("arcnet: Resetting %s (status=%Xh)\n",
1599 dev->name,inb(STATUS));
1600
1601 inb(RESET);
1602 JIFFER(RESETtime);
1603
1604 outb(CFLAGScmd|RESETclear|CONFIGclear,COMMAND);
1605
1606
1607
1608
1609 {
1610 u_char *cardmem = (u_char *) dev->mem_start;
1611 if (cardmem[0] != TESTvalue)
1612 {
1613 BUGLVL(D_INIT)
1614 printk("arcnet: reset failed: TESTvalue not present.\n");
1615 return 1;
1616 }
1617 lp->arcnum=cardmem[1];
1618 }
1619
1620
1621 recbuf=lp->recbuf=0;
1622 dev->tbusy=0;
1623
1624
1625
1626
1627
1628
1629 outb(NORXflag,INTMASK);
1630
1631
1632 outb(CONFIGcmd|EXTconf,COMMAND);
1633 JIFFER(ACKtime);
1634
1635
1636 BUGLVL(D_DURING)
1637 memset((void *)dev->mem_start,0x42,2048);
1638
1639
1640 EnableReceiver();
1641
1642
1643 return 0;
1644 }
1645
1646
1647
1648
1649
1650
1651
1652
1653 int arc_header(unsigned char *buff,struct device *dev,unsigned short type,
1654 void *daddr,void *saddr,unsigned len,struct sk_buff *skb)
1655 {
1656 struct ClientData *head = (struct ClientData *)buff;
1657 struct arcnet_local *lp=(struct arcnet_local *)(dev->priv);
1658
1659
1660 switch(type)
1661 {
1662 case ETH_P_IP:
1663 head->protocol_id=ARC_P_IP;
1664 break;
1665 case ETH_P_ARP:
1666 head->protocol_id=ARC_P_ARP;
1667 break;
1668 case ETH_P_RARP:
1669 head->protocol_id=ARC_P_RARP;
1670 break;
1671 default:
1672 printk("arcnet: I don't understand protocol %d (%Xh)\n",
1673 type,type);
1674 return 0;
1675 }
1676
1677 #if 0
1678
1679
1680
1681
1682
1683 if(saddr)
1684 memcpy(eth->h_source,saddr,dev->addr_len);
1685 else
1686 memcpy(eth->h_source,dev->dev_addr,dev->addr_len);
1687 #endif
1688
1689 #if 0
1690
1691
1692
1693
1694
1695
1696 if (dev->flags & IFF_LOOPBACK)
1697 {
1698 memset(eth->h_dest, 0, dev->addr_len);
1699 return(dev->hard_header_len);
1700 }
1701 #endif
1702
1703 head->split_flag=0;
1704 head->sequence=(lp->sequence++);
1705
1706
1707 if(daddr)
1708 {
1709 head->daddr=((u_char*)daddr)[0];
1710 return dev->hard_header_len;
1711 }
1712 else
1713 head->daddr=0;
1714
1715 return -dev->hard_header_len;
1716 }
1717
1718
1719
1720
1721
1722
1723
1724 int arc_rebuild_header(void *buff,struct device *dev,unsigned long dst,
1725 struct sk_buff *skb)
1726 {
1727 struct ClientData *head = (struct ClientData *)buff;
1728
1729
1730
1731
1732
1733 if(head->protocol_id != ARC_P_IP)
1734 {
1735 printk("arcnet: I don't understand resolve type %d (%Xh) addresses!\n",
1736 head->protocol_id,head->protocol_id);
1737 head->daddr=0;
1738
1739 return 0;
1740 }
1741
1742
1743
1744
1745 #ifdef CONFIG_INET
1746 return arp_find(&(head->daddr), dst, dev, dev->pa_addr, skb)? 1 : 0;
1747 #else
1748 return 0;
1749 #endif
1750 }
1751
1752
1753
1754
1755
1756
1757 unsigned short arc_type_trans(struct sk_buff *skb,struct device *dev)
1758 {
1759 struct ClientData *head = (struct ClientData *) skb->data;
1760
1761
1762 if (head->daddr==0)
1763 skb->pkt_type=PACKET_BROADCAST;
1764
1765 #if 0
1766 if(*eth->h_dest&1)
1767 {
1768 if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0)
1769 skb->pkt_type=PACKET_BROADCAST;
1770 else
1771 skb->pkt_type=PACKET_MULTICAST;
1772 }
1773 #endif
1774
1775 if(dev->flags&IFF_PROMISC)
1776 {
1777
1778 if (head->daddr != dev->dev_addr[0])
1779 skb->pkt_type=PACKET_OTHERHOST;
1780 }
1781
1782
1783 switch (head->protocol_id)
1784 {
1785 case ARC_P_IP: return htons(ETH_P_IP);
1786
1787 case ARC_P_ARP: return htons(ETH_P_ARP);
1788 case ARC_P_RARP: return htons(ETH_P_RARP);
1789 case 0xFA:
1790 case 0xDD:
1791 default:
1792 BUGLVL(D_DURING)
1793 printk("arcnet: received packet of unknown protocol id %d (%Xh)\n",
1794 head->protocol_id,head->protocol_id);
1795 return 0;
1796 }
1797
1798 #if 0
1799 if (ntohs(eth->h_proto) >= 1536)
1800 return eth->h_proto;
1801
1802 rawp = (unsigned char *)(eth + 1);
1803
1804 if (*(unsigned short *)rawp == 0xFFFF)
1805 return htons(ETH_P_802_3);
1806 if (*(unsigned short *)rawp == 0xAAAA)
1807 return htons(ETH_P_SNAP);
1808
1809 return htons(ETH_P_802_2);
1810 #endif
1811
1812 return htons(ETH_P_IP);
1813 }
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825