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/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. if (sc->if_type == LMC_NET) {
  52. struct net_device *dev = sc->lmc_device;
  53. /*
  54. * They set a few basics because they don't use HDLC
  55. */
  56. dev->flags |= IFF_POINTOPOINT;
  57. dev->hard_header_len = 0;
  58. dev->addr_len = 0;
  59. }
  60. lmc_trace(sc->lmc_device, "lmc_proto_attach out");
  61. }
  62. int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd)
  63. {
  64. lmc_trace(sc->lmc_device, "lmc_proto_ioctl");
  65. if (sc->if_type == LMC_PPP)
  66. return hdlc_ioctl(sc->lmc_device, ifr, cmd);
  67. return -EOPNOTSUPP;
  68. }
  69. int lmc_proto_open(lmc_softc_t *sc)
  70. {
  71. int ret = 0;
  72. lmc_trace(sc->lmc_device, "lmc_proto_open in");
  73. if (sc->if_type == LMC_PPP) {
  74. ret = hdlc_open(sc->lmc_device);
  75. if (ret < 0)
  76. printk(KERN_WARNING "%s: HDLC open failed: %d\n",
  77. sc->name, ret);
  78. }
  79. lmc_trace(sc->lmc_device, "lmc_proto_open out");
  80. return ret;
  81. }
  82. void lmc_proto_close(lmc_softc_t *sc)
  83. {
  84. lmc_trace(sc->lmc_device, "lmc_proto_close in");
  85. if (sc->if_type == LMC_PPP)
  86. hdlc_close(sc->lmc_device);
  87. lmc_trace(sc->lmc_device, "lmc_proto_close out");
  88. }
  89. __be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
  90. {
  91. lmc_trace(sc->lmc_device, "lmc_proto_type in");
  92. switch(sc->if_type){
  93. case LMC_PPP:
  94. return hdlc_type_trans(skb, sc->lmc_device);
  95. break;
  96. case LMC_NET:
  97. return htons(ETH_P_802_2);
  98. break;
  99. case LMC_RAW: /* Packet type for skbuff kind of useless */
  100. return htons(ETH_P_802_2);
  101. break;
  102. default:
  103. printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name);
  104. return htons(ETH_P_802_2);
  105. break;
  106. }
  107. lmc_trace(sc->lmc_device, "lmc_proto_tye out");
  108. }
  109. void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
  110. {
  111. lmc_trace(sc->lmc_device, "lmc_proto_netif in");
  112. switch(sc->if_type){
  113. case LMC_PPP:
  114. case LMC_NET:
  115. default:
  116. netif_rx(skb);
  117. break;
  118. case LMC_RAW:
  119. break;
  120. }
  121. lmc_trace(sc->lmc_device, "lmc_proto_netif out");
  122. }