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 <asm/system.h>
103 #include <asm/bitops.h>
104 #include <asm/io.h>
105 #include <asm/dma.h>
106 #include <errno.h>
107
108 #include <linux/netdevice.h>
109 #include <linux/etherdevice.h>
110 #include <linux/skbuff.h>
111 #include "arp.h"
112
113
114
115
116
117
118
119
120
121 #define D_OFF 0
122 #define D_NORMAL 1
123 #define D_INIT 2
124 #define D_EXTRA 3
125 #define D_DURING 4
126 #define D_TX 5
127 #define D_RX 6
128
129 #ifndef NET_DEBUG
130 #define NET_DEBUG D_INIT
131 #endif
132 static unsigned int net_debug = NET_DEBUG;
133
134 #ifndef HAVE_AUTOIRQ
135
136 extern void autoirq_setup(int waittime);
137 extern int autoirq_report(int waittime);
138
139
140 extern struct device *irq2dev_map[16];
141 #endif
142
143 #ifndef HAVE_PORTRESERVE
144 #define check_region(ioaddr, size) 0
145 #define snarf_region(ioaddr, size); do ; while (0)
146 #endif
147
148
149 #define BUGLVL(x) if (net_debug>=x)
150
151
152 #define ETHERCARD_TOTAL_SIZE 16
153
154
155
156
157 #define INTMASK (ioaddr+0)
158 #define STATUS (ioaddr+0)
159 #define COMMAND (ioaddr+1)
160 #define RESET (ioaddr+8)
161
162
163 #define RESETtime 40
164 #define XMITtime 10
165 #define ACKtime 10
166
167
168
169
170
171
172
173
174
175 #define MTU (253+EXTRA_CLIENTDATA)
176 #define MinTU (257+EXTRA_CLIENTDATA)
177 #define XMTU (508+EXTRA_CLIENTDATA)
178
179
180 #define TXFREEflag 0x001
181 #define TXACKflag 0x002
182 #define RECONflag 0x004
183 #define TESTflag 0x008
184 #define RESETflag 0x010
185 #define RES1flag 0x020
186 #define RES2flag 0x040
187 #define NORXflag 0x080
188
189
190
191
192
193
194 #define NOTXcmd 0x001
195 #define NORXcmd 0x002
196 #define TXcmd 0x003
197 #define RXcmd 0x004
198 #define CONFIGcmd 0x005
199 #define CFLAGScmd 0x006
200 #define TESTcmd 0x007
201
202
203 #define RESETclear 0x008
204 #define CONFIGclear 0x010
205
206
207 #define TESTload 0x008
208
209
210 #define TESTvalue 0321
211
212
213 #define RXbcasts 0x080
214
215
216 #define NORMALconf 0x000
217 #define EXTconf 0x008
218
219
220
221 #define EnableReceiver() outb(RXcmd|(recbuf<<3)|RXbcasts,COMMAND)
222 #define TXbuf 2
223
224
225 #define ARC_P_IP 212
226 #define ARC_P_ARP 213
227 #define ARC_P_RARP 214
228
229
230 #define TIMERval (HZ/8)
231
232
233 #define NORMAL 0
234 #define EXTENDED 1
235 #define EXCEPTION 2
236
237
238 struct HardHeader
239 {
240 u_char source,
241 destination,
242 offset1,
243 offset2;
244 };
245
246
247 union ArcPacket
248 {
249 struct HardHeader hardheader;
250 u_char raw[512];
251 };
252
253
254
255
256
257 struct ClientData
258 {
259
260 u_char daddr;
261
262
263
264 u_char stupid;
265
266
267 u_char protocol_id,
268 split_flag;
269 u_short sequence;
270 };
271 #define EXTRA_CLIENTDATA (sizeof(struct ClientData)-4)
272
273
274
275
276
277 struct Incoming
278 {
279 struct sk_buff *skb;
280 unsigned char lastpacket,
281 numpackets;
282 u_short sequence;
283 };
284
285
286
287 struct arcnet_local {
288 struct enet_statistics stats;
289 u_char arcnum;
290 u_short sequence;
291 u_char recbuf;
292 int intx;
293 struct timer_list timer;
294 struct Incoming incoming[256];
295 };
296
297
298
299
300 extern int arcnet_probe(struct device *dev);
301 static int arcnet_memprobe(struct device *dev,u_char *addr);
302 static int arcnet_ioprobe(struct device *dev, short ioaddr);
303
304 static int arcnet_open(struct device *dev);
305 static int arcnet_close(struct device *dev);
306
307 static int arcnet_send_packet(struct sk_buff *skb, struct device *dev);
308 static void careful_xmit_wait(struct device *dev);
309 static int arcnet_tx(struct device *dev,struct ClientData *hdr,short length,
310 char *data);
311
312 static void arcnet_interrupt(int reg_ptr);
313 static void arcnet_inthandler(struct device *dev);
314 static void arcnet_rx(struct device *dev,int recbuf);
315
316
317 static void arcnet_timer(unsigned long arg);
318
319 static struct enet_statistics *arcnet_get_stats(struct device *dev);
320 static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
321
322
323 int arc_header(unsigned char *buff,struct device *dev,unsigned short type,
324 void *daddr,void *saddr,unsigned len,struct sk_buff *skb);
325 int arc_rebuild_header(void *eth,struct device *dev,unsigned long raddr,
326 struct sk_buff *skb);
327 unsigned short arc_type_trans(struct sk_buff *skb,struct device *dev);
328
329
330 #define tx_done(dev) 1
331 #define JIFFER(time) for (delayval=jiffies+(time); delayval>=jiffies;);
332 static int arcnet_reset(struct device *dev);
333
334
335
336
337
338
339
340
341 int
342 arcnet_probe(struct device *dev)
343 {
344
345
346
347 int *port, ports[] = {
348 0x300,0x2E0,0x2F0,0x2D0,
349
350 0x200,0x210,0x220,0x230,0x240,0x250,0x260,0x270,
351 0x280,0x290,0x2a0,0x2b0,0x2c0,
352 0x310,0x320,0x330,0x340,0x350,0x360,0x370,
353 0x380,0x390,0x3a0,0x3b0,0x3c0,0x3d0,0x3e0,0x3f0,
354
355 0};
356
357
358 unsigned long *addr, addrs[] = {0xD0000,0xE0000,0xA0000,0xB0000,
359 0xC0000,0xF0000,
360
361 0xE1000,
362 0xDD000,0xDC000,
363 0xD9000,0xD8000,0xD5000,0xD4000,0xD1000,
364 0xCD000,0xCC000,
365 0xC9000,0xC8000,0xC5000,0xC4000,
366
367 0};
368 int base_addr=dev->base_addr, status=0,delayval;
369 struct arcnet_local *lp;
370
371 if (net_debug) printk(version);
372
373 BUGLVL(D_INIT)
374 printk("arcnet: given: base %Xh, IRQ %Xh, shmem %lXh\n",
375 dev->base_addr,dev->irq,dev->mem_start);
376
377 if (base_addr > 0x1ff)
378 status=arcnet_ioprobe(dev, base_addr);
379 else if (base_addr > 0)
380 return ENXIO;
381 else for (port = &ports[0]; *port; port++)
382 {
383 int ioaddr = *port;
384 if (check_region(ioaddr, ETHERCARD_TOTAL_SIZE))
385 {
386 BUGLVL(D_INIT)
387 printk("arcnet: Skipping %Xh because of check_region...\n",
388 ioaddr);
389 continue;
390 }
391
392 status=arcnet_ioprobe(dev, ioaddr);
393 if (!status) break;
394 }
395
396 if (status) return status;
397
398
399
400
401 BUGLVL(D_INIT)
402 printk("arcnet: ioprobe okay! Waiting for reset...\n");
403 JIFFER(100);
404
405
406 BUGLVL(D_INIT)
407 printk("arcnet: starting memory probe, given %lXh\n",
408 dev->mem_start);
409 if (dev->mem_start)
410 {
411 status=arcnet_memprobe(dev,(u_char *)dev->mem_start);
412 if (status) return status;
413 }
414 else
415 {
416 for (addr = &addrs[0]; *addr; addr++) {
417 status=arcnet_memprobe(dev,(u_char *)(*addr));
418 if (!status) break;
419 }
420
421 if (status) return status;
422 }
423
424
425 { int irqval = request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet");
426 if (irqval) {
427 printk("%s: unable to get IRQ %d (irqval=%d).\n", dev->name,
428 dev->irq, irqval);
429 return EAGAIN;
430 }
431 }
432
433
434 snarf_region(dev->base_addr, ETHERCARD_TOTAL_SIZE);
435
436 printk("%s: ARCnet card found at %03Xh, IRQ %d, ShMem at %lXh.\n", dev->name,
437 dev->base_addr, dev->irq, dev->mem_start);
438
439
440 dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
441 memset(dev->priv, 0, sizeof(struct arcnet_local));
442 lp=(struct arcnet_local *)(dev->priv);
443
444 dev->open = arcnet_open;
445 dev->stop = arcnet_close;
446 dev->hard_start_xmit = arcnet_send_packet;
447 dev->get_stats = arcnet_get_stats;
448 #ifdef HAVE_MULTICAST
449 dev->set_multicast_list = &set_multicast_list;
450 #endif
451
452
453 ether_setup(dev);
454
455
456
457 dev->type=ARPHRD_ARCNET;
458 dev->hard_header_len=sizeof(struct ClientData);
459 BUGLVL(D_EXTRA)
460 printk("arcnet: ClientData header size is %d.\narcnet: HardHeader size is %d.\n",
461 sizeof(struct ClientData),sizeof(struct HardHeader));
462 #if LIMIT_MTU
463 dev->mtu=512-sizeof(struct HardHeader)+EXTRA_CLIENTDATA;
464 #endif
465
466
467
468 dev->addr_len=1;
469 dev->broadcast[0]=0x00;
470
471 BUGLVL(D_INIT) printk("arcnet: arcnet_probe: resetting card.\n");
472 arcnet_reset(dev);
473 JIFFER(50);
474 BUGLVL(D_NORMAL)
475 printk("arcnet: We appear to be station %d (%02Xh)\n",
476 lp->arcnum,lp->arcnum);
477 if (lp->arcnum==0)
478 printk("arcnet: WARNING! Station address 0 is reserved for broadcasts!\n");
479 if (lp->arcnum==255)
480 printk("arcnet: WARNING! Station address 255 may confuse DOS networking programs!\n");
481 dev->dev_addr[0]=lp->arcnum;
482 lp->sequence=1;
483 lp->recbuf=0;
484
485 dev->hard_header = arc_header;
486
487 dev->rebuild_header = arc_rebuild_header;
488 dev->type_trans = arc_type_trans;
489
490 return 0;
491 }
492
493 int arcnet_ioprobe(struct device *dev, short ioaddr)
494 {
495 int delayval,airq;
496
497 BUGLVL(D_INIT)
498 printk("arcnet: probing address %Xh\n",ioaddr);
499
500 BUGLVL(D_INIT)
501 printk("arcnet: status1=%Xh\n",inb(STATUS));
502
503
504
505
506
507
508
509
510 inb(RESET);
511 JIFFER(RESETtime);
512
513
514 if (inb(STATUS)==0xFF)
515 {
516 BUGLVL(D_INIT)
517 printk("arcnet: probe failed. Status port empty.\n");
518 return ENODEV;
519 }
520
521
522
523
524
525
526 {
527 int initval,curval;
528
529 curval=initval=inb(COMMAND);
530 delayval=jiffies+5;
531 while (delayval>=jiffies && curval==initval)
532 curval=inb(COMMAND);
533
534 if (curval==initval)
535 {
536 printk("arcnet: probe failed. never-changing command port (%02Xh).\n",
537 initval);
538 return ENODEV;
539 }
540 }
541
542 BUGLVL(D_INIT)
543 printk("arcnet: status2=%Xh\n",inb(STATUS));
544
545
546 outb(CFLAGScmd|RESETclear|CONFIGclear,COMMAND);
547 JIFFER(ACKtime);
548 if (inb(STATUS) & RESETflag)
549 {
550 BUGLVL(D_INIT)
551 printk("arcnet: probe failed. eternal reset flag1...(status=%Xh)\n",
552 inb(STATUS));
553 return ENODEV;
554 }
555
556
557 autoirq_setup(0);
558
559
560 outb(RESETflag,INTMASK);
561
562
563 inb(RESET);
564 JIFFER(RESETtime);
565
566 BUGLVL(D_INIT)
567 printk("arcnet: status3=%Xh\n",inb(STATUS));
568
569
570 outb(RESETflag,INTMASK);
571
572
573 outb(CFLAGScmd|RESETclear|CONFIGclear,COMMAND);
574 JIFFER(ACKtime);
575
576 BUGLVL(D_INIT)
577 printk("arcnet: status4=%Xh\n",inb(STATUS));
578
579
580 inb(RESET);
581 JIFFER(RESETtime);
582
583 BUGLVL(D_INIT)
584 printk("arcnet: status5=%Xh\n",inb(STATUS));
585
586 airq = autoirq_report(0);
587 if (net_debug>=D_INIT && airq)
588 printk("arcnet: autoirq is %d\n", airq);
589
590
591
592
593 if (!airq && !(dev->base_addr && dev->irq))
594 {
595 BUGLVL(D_INIT)
596 printk("arcnet: probe failed. no autoirq...\n");
597 return ENODEV;
598 }
599
600
601
602 if (inb(STATUS) & RESETflag)
603 {
604
605 outb(CFLAGScmd|RESETclear|CONFIGclear,COMMAND);
606 JIFFER(ACKtime);
607 }
608
609 if (inb(STATUS) & RESETflag)
610 {
611 BUGLVL(D_INIT)
612 printk("arcnet: probe failed. eternal reset flag...(status=%Xh)\n",
613 inb(STATUS));
614 return ENODEV;
615 }
616
617
618 if (!dev->base_addr) dev->base_addr=ioaddr;
619
620 if (dev->irq < 2)
621 {
622
623 dev->irq=airq;
624 }
625 else if (dev->irq == 2)
626 {
627 if (net_debug)
628 printk("arcnet: IRQ2 == IRQ9, don't worry.\n");
629 dev->irq = 9;
630 }
631
632 BUGLVL(D_INIT)
633 printk("arcnet: irq and base address seem okay. (%Xh, IRQ %d)\n",
634 dev->base_addr,dev->irq);
635 return 0;
636 }
637
638
639
640
641
642 int arcnet_memprobe(struct device *dev,u_char *addr)
643 {
644 BUGLVL(D_INIT)
645 printk("arcnet: probing memory at %lXh\n",(u_long)addr);
646
647 dev->mem_start=0;
648
649 #ifdef STRICT_MEM_DETECT
650
651 if (addr[0]!=TESTvalue)
652 {
653 BUGLVL(D_INIT)
654 printk("arcnet: probe failed. addr=%lXh, addr[0]=%Xh (not %Xh)\n",
655 (unsigned long)addr,addr[0],TESTvalue);
656 return ENODEV;
657 }
658
659
660 addr[0]=0x42;
661 if (addr[0]!=0x42)
662 {
663 BUGLVL(D_INIT)
664 printk("arcnet: probe failed. addr=%lXh, addr[0]=%Xh (not 42h)\n",
665 (unsigned long)addr,addr[0]);
666 return ENODEV;
667 }
668 #else
669 if (addr[0]!=TESTvalue)
670 {
671 BUGLVL(D_INIT)
672 printk("arcnet: probe failed. addr=%lXh, addr[0]=%Xh (not %Xh)\n",
673 (unsigned long)addr,addr[0],TESTvalue);
674 return ENODEV;
675 }
676 #endif
677
678
679 dev->mem_start=(unsigned long)addr;
680 dev->mem_end=dev->mem_start+512*4-1;
681 dev->rmem_start=dev->mem_start+512*0;
682 dev->rmem_end=dev->mem_start+512*2-1;
683
684 return 0;
685 }
686
687
688
689
690
691
692
693
694
695 static int
696 arcnet_open(struct device *dev)
697 {
698 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
699
700
701 if (net_debug) printk(version);
702
703 #if 0
704
705
706 if (request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet")) {
707 return -EAGAIN;
708 }
709 #endif
710
711 irq2dev_map[dev->irq] = dev;
712
713
714 BUGLVL(D_EXTRA) printk("arcnet: arcnet_open: resetting card.\n");
715 if (arcnet_reset(dev)) return -ENODEV;
716
717
718
719
720
721
722 dev->tbusy = 0;
723 dev->interrupt = 0;
724 dev->start = 1;
725
726
727 init_timer(&lp->timer);
728 lp->timer.expires = TIMERval;
729 lp->timer.data = (unsigned long)dev;
730 lp->timer.function = &arcnet_timer;
731 #ifdef USE_TIMER_HANDLER
732 add_timer(&lp->timer);
733 #endif
734
735 return 0;
736 }
737
738
739
740 static int
741 arcnet_close(struct device *dev)
742 {
743 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
744 int ioaddr = dev->base_addr, delayval;
745
746
747
748 dev->tbusy = 1;
749 dev->start = 0;
750
751
752 del_timer(&lp->timer);
753
754
755
756
757
758 outb(0,INTMASK);
759 outb(NOTXcmd,COMMAND);
760 JIFFER(ACKtime);
761 outb(NORXcmd,COMMAND);
762
763 #if 0
764
765 outw(0x00, ioaddr+0);
766 free_irq(dev->irq);
767 irq2dev_map[dev->irq] = 0;
768 #endif
769
770
771
772 return 0;
773 }
774
775
776 static int
777 arcnet_send_packet(struct sk_buff *skb, struct device *dev)
778 {
779 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
780 int ioaddr=dev->base_addr,stat=0;
781
782
783 lp->intx++;
784
785 BUGLVL(D_DURING)
786 printk("arcnet: transmit requested (status=%Xh, inTX=%d)\n",
787 inb(STATUS),lp->intx);
788
789 if (dev->tbusy)
790 {
791
792
793 int tickssofar = jiffies - dev->trans_start;
794 int recbuf=lp->recbuf;
795 int status=inb(STATUS);
796
797 if (tickssofar < 5) return 1;
798
799 BUGLVL(D_INIT)
800 printk("arcnet: transmit timed out (status=%Xh, inTX=%d, tickssofar=%d)\n",
801 status,lp->intx,tickssofar);
802
803
804
805
806 if (status&NORXflag) EnableReceiver();
807 if (!(status&TXFREEflag)) outb(NOTXcmd,COMMAND);
808 dev->tbusy=0;
809 mark_bh(NET_BH);
810 dev->trans_start = jiffies;
811 lp->intx--;
812 return 1;
813 }
814
815
816
817
818 if (skb == NULL) {
819 BUGLVL(D_INIT)
820 printk("arcnet: tx passed null skb (status=%Xh, inTX=%d, tickssofar=%ld)\n",
821 inb(STATUS),lp->intx,jiffies-dev->trans_start);
822 dev_tint(dev);
823 lp->intx--;
824 return 0;
825 }
826
827
828
829 if (set_bit(0, (void*)&dev->tbusy) != 0)
830 {
831 printk("arcnet: Transmitter called with busy bit set! (status=%Xh, inTX=%d, tickssofar=%ld)\n",
832 inb(STATUS),lp->intx,jiffies-dev->trans_start);
833 stat=-EBUSY;
834 }
835 else {
836 short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
837 struct ClientData *hdr=(struct ClientData*)skb->data;
838
839 if (length<=XMTU)
840 {
841 BUGLVL(D_TX) printk("arcnet: not splitting %d-byte packet. (split_flag=%d)\n",
842 length,hdr->split_flag);
843 BUGLVL(D_INIT) if (hdr->split_flag)
844 printk("arcnet: short packet has split_flag set?! (split_flag=%d)\n",
845 hdr->split_flag);
846 stat=arcnet_tx(dev,hdr,
847 length-sizeof(struct ClientData),
848 ((char *)skb->data)+sizeof(struct ClientData));
849 }
850 else
851 {
852 u_char *data=(u_char *)skb->data
853 + sizeof(struct ClientData);
854 int dataleft=length-sizeof(struct ClientData),
855 maxsegsize=XMTU-sizeof(struct ClientData),
856 numsegs=(dataleft+maxsegsize-1)/maxsegsize,
857 seglen,segnum=0;
858
859 BUGLVL(D_TX) printk("arcnet: packet (%d bytes) split into %d fragments:\n",
860 length,numsegs);
861
862 while (!stat && dataleft)
863 {
864 if (!segnum)
865 hdr->split_flag=((numsegs-2)<<1)+1;
866 else
867 hdr->split_flag=segnum<<1;
868
869 seglen=maxsegsize;
870 if (seglen>dataleft) seglen=dataleft;
871
872 BUGLVL(D_TX) printk("arcnet: packet #%d (%d bytes) of %d (%d total), splitflag=%d\n",
873 segnum+1,seglen,numsegs,length,hdr->split_flag);
874
875 stat=arcnet_tx(dev,hdr,seglen,data);
876
877 dataleft-=seglen;
878 data+=seglen;
879 segnum++;
880
881 #if 0
882
883 hdr->sequence++;
884 lp->sequence++;
885 #endif
886 }
887 }
888
889
890
891
892
893 if (!stat) dev_kfree_skb(skb, FREE_WRITE);
894
895
896 if (stat!=-EBUSY)
897 {
898 dev->tbusy=0;
899 mark_bh(NET_BH);
900
901
902
903 }
904 }
905
906 lp->intx--;
907
908 if (!stat) lp->stats.tx_packets++;
909 return stat;
910 }
911
912 #ifdef CAREFUL_XMIT
913 static void careful_xmit_wait(struct device *dev)
914 {
915 int ioaddr=dev->base_addr;
916 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
917
918
919 while ( !(inb(STATUS)&TXFREEflag) )
920 {
921 if (jiffies-dev->trans_start > 20 || !dev->tbusy)
922 {
923 BUGLVL(D_INIT)
924 printk("arcnet: CAREFUL_XMIT timeout. (busy=%d, status=%Xh)\n",
925 dev->tbusy,inb(STATUS));
926 lp->stats.tx_errors++;
927
928 outb(NOTXcmd,COMMAND);
929 return;
930 }
931 }
932 BUGLVL(D_TX) printk("arcnet: transmit completed successfully. (status=%Xh)\n",
933 inb(STATUS));
934 }
935 #endif
936
937 static int
938 arcnet_tx(struct device *dev,struct ClientData *hdr,short length,
939 char *data)
940 {
941 int ioaddr = dev->base_addr;
942 #if 0
943 struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
944 #endif
945 struct ClientData *arcsoft;
946 union ArcPacket *arcpacket =
947 (union ArcPacket *)(dev->mem_start+512*TXbuf);
948 u_char pkttype;
949 int offset;
950 short daddr;
951
952 length+=sizeof(struct ClientData);
953
954 BUGLVL(D_TX)
955 printk("arcnet: arcnet_tx: hdr:%ph, length:%d, data:%ph\n",
956 hdr,length,data);
957
958 #if 0
959
960 if (! (inb(STATUS) & TXFREEflag))
961 {
962 BUGLVL(D_TX)
963 printk("arcnet: transmitter in use! (status=%Xh)\n",
964 inb(STATUS));
965 return -EBUSY;
966 }
967 #endif
968
969
970
971
972
973 #ifdef CAREFUL_XMIT
974 careful_xmit_wait(dev);
975 #endif
976
977
978 BUGLVL(D_DURING)
979 memset((void *)dev->mem_start+TXbuf*512,0x42,512);
980
981 daddr=arcpacket->hardheader.destination=hdr->daddr;
982
983
984 if (length<=MTU)
985 {
986 pkttype=NORMAL;
987
988 arcpacket->hardheader.offset1=offset=256-length
989 + EXTRA_CLIENTDATA;
990 arcsoft=(struct ClientData *)
991 (&arcpacket->raw[offset-EXTRA_CLIENTDATA]);
992 }
993 else if (length>=MinTU)
994 {
995 pkttype=EXTENDED;
996
997 arcpacket->hardheader.offset1=0;
998 arcpacket->hardheader.offset2=offset=512-length
999 + EXTRA_CLIENTDATA;
1000 arcsoft=(struct ClientData *)
1001 (&arcpacket->raw[offset-EXTRA_CLIENTDATA]);
1002 }
1003 else
1004 {
1005 pkttype=EXCEPTION;
1006
1007 arcpacket->hardheader.offset1=0;
1008 arcpacket->hardheader.offset2=offset=512-length-4
1009 + EXTRA_CLIENTDATA;
1010 arcsoft=(struct ClientData *)
1011 (&arcpacket->raw[offset+4-EXTRA_CLIENTDATA]);
1012
1013
1014
1015
1016
1017 arcpacket->raw[offset+0]=arcsoft->protocol_id;
1018 arcpacket->raw[offset+1]=0xFF;
1019 arcpacket->raw[offset+2]=0xFF;
1020 arcpacket->raw[offset+3]=0xFF;
1021 }
1022
1023
1024
1025
1026
1027 memcpy((u_char*)arcsoft+EXTRA_CLIENTDATA,
1028 (u_char*)hdr+EXTRA_CLIENTDATA,
1029 sizeof(struct ClientData)-EXTRA_CLIENTDATA);
1030 memcpy((u_char*)arcsoft+sizeof(struct ClientData),
1031 data,
1032 length-sizeof(struct ClientData));
1033
1034 BUGLVL(D_DURING) printk("arcnet: transmitting packet to station %02Xh (%d bytes, type=%d)\n",
1035 daddr,length,pkttype);
1036
1037 BUGLVL(D_TX)
1038 {
1039 int countx,county;
1040
1041 printk("arcnet: packet dump [tx] follows:");
1042
1043 for (county=0; county<16+(pkttype!=NORMAL)*16; county++)
1044 {
1045 printk("\n[%04X] ",county*16);
1046 for (countx=0; countx<16; countx++)
1047 printk("%02X ",
1048 arcpacket->raw[county*16+countx]);
1049 }
1050
1051 printk("\n");
1052 }
1053
1054
1055
1056 outb(TXcmd|(TXbuf<<3),COMMAND);
1057
1058 dev->trans_start = jiffies;
1059
1060 BUGLVL(D_TX) printk("arcnet: transmit started successfully. (status=%Xh)\n",
1061 inb(STATUS));
1062 #ifdef CAREFUL_XMIT
1063 #if 0
1064 careful_xmit_wait(dev);
1065
1066
1067
1068
1069
1070 if (daddr && !(inb(STATUS)&TXACKflag))
1071 {
1072 BUGLVL(D_INIT)
1073 printk("arcnet: transmit not acknowledged. (status=%Xh, daddr=%02Xh)\n",
1074 inb(STATUS),daddr);
1075 lp->stats.tx_errors++;
1076 return -ENONET;
1077 }
1078 #endif
1079 #endif
1080
1081 return 0;
1082 }
1083
1084
1085
1086
1087 static void
1088 arcnet_interrupt(int reg_ptr)
1089 {
1090 int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
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