lmc_proto.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) 1997-2000 LAN Media Corporation (LMC)
  3. * All rights reserved. www.lanmedia.com
  4. *
  5. * This code is written by:
  6. * Andrew Stanley-Jones (asj@cban.com)
  7. * Rob Braun (bbraun@vix.com),
  8. * Michael Graff (explorer@vix.com) and
  9. * Matt Thomas (matt@3am-software.com).
  10. *
  11. * With Help By:
  12. * David Boggs
  13. * Ron Crane
  14. * Allan Cox
  15. *
  16. * This software may be used and distributed according to the terms
  17. * of the GNU General Public License version 2, incorporated herein by reference.
  18. *
  19. * Driver for the LanMedia LMC5200, LMC5245, LMC1000, LMC1200 cards.
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/string.h>
  23. #include <linux/timer.h>
  24. #include <linux/ptrace.h>
  25. #include <linux/errno.h>
  26. #include <linux/ioport.h>
  27. #include <linux/slab.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/in.h>
  30. #include <linux/if_arp.h>
  31. #include <linux/netdevice.h>
  32. #include <linux/etherdevice.h>
  33. #include <linux/skbuff.h>
  34. #include <linux/inet.h>
  35. #include <linux/workqueue.h>
  36. #include <linux/proc_fs.h>
  37. #include <linux/bitops.h>
  38. #include <asm/processor.h> /* Processor type for cache alignment. */
  39. #include <asm/io.h>
  40. #include <asm/dma.h>
  41. #include <linux/smp.h>
  42. #include "lmc.h"
  43. #include "lmc_var.h"
  44. #include "lmc_debug.h"
  45. #include "lmc_ioctl.h"
  46. #include "lmc_proto.h"
  47. // attach
  48. void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
  49. {
  50. lmc_trace(sc->lmc_device, "lmc_proto_attach in");
  51. switch(sc->if_type){
  52. case LMC_PPP:
  53. {
  54. struct net_device *dev = sc->lmc_device;
  55. dev->do_ioctl = lmc_ioctl;
  56. }
  57. break;
  58. case LMC_NET:
  59. {
  60. struct net_device *dev = sc->lmc_device;
  61. /*
  62. * They set a few basics because they don't use HDLC
  63. */
  64. dev->flags |= IFF_POINTOPOINT;
  65. dev->hard_header_len = 0;
  66. dev->addr_len = 0;
  67. }
  68. case LMC_RAW: /* Setup the task queue, maybe we should notify someone? */
  69. {
  70. }
  71. default:
  72. break;
  73. }
  74. lmc_trace(sc->lmc_device, "lmc_proto_attach out");
  75. }
  76. int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd)
  77. {
  78. lmc_trace(sc->lmc_device, "lmc_proto_ioctl");
  79. if (sc->if_type == LMC_PPP)
  80. return hdlc_ioctl(sc->lmc_device, ifr, cmd);
  81. return -EOPNOTSUPP;
  82. }
  83. int lmc_proto_open(lmc_softc_t *sc)
  84. {
  85. int ret = 0;
  86. lmc_trace(sc->lmc_device, "lmc_proto_open in");
  87. if (sc->if_type == LMC_PPP) {
  88. ret = hdlc_open(sc->lmc_device);
  89. if (ret < 0)
  90. printk(KERN_WARNING "%s: HDLC open failed: %d\n",
  91. sc->name, ret);
  92. }
  93. lmc_trace(sc->lmc_device, "lmc_proto_open out");
  94. return ret;
  95. }
  96. void lmc_proto_close(lmc_softc_t *sc)
  97. {
  98. lmc_trace(sc->lmc_device, "lmc_proto_close in");
  99. if (sc->if_type == LMC_PPP)
  100. hdlc_close(sc->lmc_device);
  101. lmc_trace(sc->lmc_device, "lmc_proto_close out");
  102. }
  103. __be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
  104. {
  105. lmc_trace(sc->lmc_device, "lmc_proto_type in");
  106. switch(sc->if_type){
  107. case LMC_PPP:
  108. return hdlc_type_trans(skb, sc->lmc_device);
  109. break;
  110. case LMC_NET:
  111. return htons(ETH_P_802_2);
  112. break;
  113. case LMC_RAW: /* Packet type for skbuff kind of useless */
  114. return htons(ETH_P_802_2);
  115. break;
  116. default:
  117. printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name);
  118. return htons(ETH_P_802_2);
  119. break;
  120. }
  121. lmc_trace(sc->lmc_device, "lmc_proto_tye out");
  122. }
  123. void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
  124. {
  125. lmc_trace(sc->lmc_device, "lmc_proto_netif in");
  126. switch(sc->if_type){
  127. case LMC_PPP:
  128. case LMC_NET:
  129. default:
  130. netif_rx(skb);
  131. break;
  132. case LMC_RAW:
  133. break;
  134. }
  135. lmc_trace(sc->lmc_device, "lmc_proto_netif out");
  136. }