lmc_proto.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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/interrupt.h>
  28. #include <linux/in.h>
  29. #include <linux/if_arp.h>
  30. #include <linux/netdevice.h>
  31. #include <linux/etherdevice.h>
  32. #include <linux/skbuff.h>
  33. #include <linux/inet.h>
  34. #include <linux/workqueue.h>
  35. #include <linux/proc_fs.h>
  36. #include <linux/bitops.h>
  37. #include <asm/processor.h> /* Processor type for cache alignment. */
  38. #include <asm/io.h>
  39. #include <asm/dma.h>
  40. #include <linux/smp.h>
  41. #include "lmc.h"
  42. #include "lmc_var.h"
  43. #include "lmc_debug.h"
  44. #include "lmc_ioctl.h"
  45. #include "lmc_proto.h"
  46. // attach
  47. void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
  48. {
  49. lmc_trace(sc->lmc_device, "lmc_proto_attach in");
  50. if (sc->if_type == LMC_NET) {
  51. struct net_device *dev = sc->lmc_device;
  52. /*
  53. * They set a few basics because they don't use HDLC
  54. */
  55. dev->flags |= IFF_POINTOPOINT;
  56. dev->hard_header_len = 0;
  57. dev->addr_len = 0;
  58. }
  59. lmc_trace(sc->lmc_device, "lmc_proto_attach out");
  60. }
  61. int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd)
  62. {
  63. lmc_trace(sc->lmc_device, "lmc_proto_ioctl");
  64. if (sc->if_type == LMC_PPP)
  65. return hdlc_ioctl(sc->lmc_device, ifr, cmd);
  66. return -EOPNOTSUPP;
  67. }
  68. int lmc_proto_open(lmc_softc_t *sc)
  69. {
  70. int ret = 0;
  71. lmc_trace(sc->lmc_device, "lmc_proto_open in");
  72. if (sc->if_type == LMC_PPP) {
  73. ret = hdlc_open(sc->lmc_device);
  74. if (ret < 0)
  75. printk(KERN_WARNING "%s: HDLC open failed: %d\n",
  76. sc->name, ret);
  77. }
  78. lmc_trace(sc->lmc_device, "lmc_proto_open out");
  79. return ret;
  80. }
  81. void lmc_proto_close(lmc_softc_t *sc)
  82. {
  83. lmc_trace(sc->lmc_device, "lmc_proto_close in");
  84. if (sc->if_type == LMC_PPP)
  85. hdlc_close(sc->lmc_device);
  86. lmc_trace(sc->lmc_device, "lmc_proto_close out");
  87. }
  88. __be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
  89. {
  90. lmc_trace(sc->lmc_device, "lmc_proto_type in");
  91. switch(sc->if_type){
  92. case LMC_PPP:
  93. return hdlc_type_trans(skb, sc->lmc_device);
  94. break;
  95. case LMC_NET:
  96. return htons(ETH_P_802_2);
  97. break;
  98. case LMC_RAW: /* Packet type for skbuff kind of useless */
  99. return htons(ETH_P_802_2);
  100. break;
  101. default:
  102. printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name);
  103. return htons(ETH_P_802_2);
  104. break;
  105. }
  106. lmc_trace(sc->lmc_device, "lmc_proto_tye out");
  107. }
  108. void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
  109. {
  110. lmc_trace(sc->lmc_device, "lmc_proto_netif in");
  111. switch(sc->if_type){
  112. case LMC_PPP:
  113. case LMC_NET:
  114. default:
  115. netif_rx(skb);
  116. break;
  117. case LMC_RAW:
  118. break;
  119. }
  120. lmc_trace(sc->lmc_device, "lmc_proto_netif out");
  121. }