etherif.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. enum {
  10. MaxEther = 48,
  11. Ntypes = 8,
  12. };
  13. typedef struct Ether Ether;
  14. struct Ether {
  15. ISAConf ISAConf; /* hardware info */
  16. int ctlrno;
  17. int tbdf; /* type+busno+devno+funcno */
  18. uint8_t ea[Eaddrlen];
  19. void (*attach)(Ether*); /* filled in by reset routine */
  20. void (*detach)(Ether*);
  21. void (*transmit)(Ether*);
  22. void (*interrupt)(Ureg*, void*);
  23. int32_t (*ifstat)(Ether*, void*, int32_t, uint32_t);
  24. int32_t (*ctl)(Ether*, void*, int32_t); /* custom ctl messages */
  25. void (*power)(Ether*, int); /* power on/off */
  26. void (*shutdown)(Ether*); /* shutdown hardware before reboot */
  27. void *ctlr;
  28. Queue* oq;
  29. Netif Netif;
  30. };
  31. extern Block* etheriq(Ether*, Block*, int);
  32. extern void addethercard(char*, int(*)(Ether*));
  33. extern uint32_t ethercrc(unsigned char*, int);
  34. extern int parseether(unsigned char*, char*);
  35. #define NEXT(x, l) (((x)+1)%(l))
  36. #define PREV(x, l) (((x) == 0) ? (l)-1: (x)-1)