Lines Matching refs:dev

45 static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,  in hdlc_rcv()  argument
51 if (!(dev->priv_flags & IFF_WAN_HDLC)) { in hdlc_rcv()
56 hdlc = dev_to_hdlc(dev); in hdlc_rcv()
58 if (!net_eq(dev_net(dev), &init_net)) { in hdlc_rcv()
67 netdev_tx_t hdlc_start_xmit(struct sk_buff *skb, struct net_device *dev) in hdlc_start_xmit() argument
69 hdlc_device *hdlc = dev_to_hdlc(dev); in hdlc_start_xmit()
72 return hdlc->proto->xmit(skb, dev); in hdlc_start_xmit()
74 return hdlc->xmit(skb, dev); /* call hardware driver directly */ in hdlc_start_xmit()
78 static inline void hdlc_proto_start(struct net_device *dev) in hdlc_proto_start() argument
80 hdlc_device *hdlc = dev_to_hdlc(dev); in hdlc_proto_start()
83 hdlc->proto->start(dev); in hdlc_proto_start()
86 static inline void hdlc_proto_stop(struct net_device *dev) in hdlc_proto_stop() argument
88 hdlc_device *hdlc = dev_to_hdlc(dev); in hdlc_proto_stop()
91 hdlc->proto->stop(dev); in hdlc_proto_stop()
97 struct net_device *dev = netdev_notifier_info_to_dev(ptr); in hdlc_device_event() local
102 if (!net_eq(dev_net(dev), &init_net)) in hdlc_device_event()
105 if (!(dev->priv_flags & IFF_WAN_HDLC)) in hdlc_device_event()
111 on = netif_carrier_ok(dev); in hdlc_device_event()
115 dev->name, on); in hdlc_device_event()
118 hdlc = dev_to_hdlc(dev); in hdlc_device_event()
130 netdev_info(dev, "Carrier detected\n"); in hdlc_device_event()
131 hdlc_proto_start(dev); in hdlc_device_event()
133 netdev_info(dev, "Carrier lost\n"); in hdlc_device_event()
134 hdlc_proto_stop(dev); in hdlc_device_event()
143 int hdlc_open(struct net_device *dev) in hdlc_open() argument
145 hdlc_device *hdlc = dev_to_hdlc(dev); in hdlc_open()
147 printk(KERN_DEBUG "%s: hdlc_open() carrier %i open %i\n", dev->name, in hdlc_open()
155 int result = hdlc->proto->open(dev); in hdlc_open()
164 netdev_info(dev, "Carrier detected\n"); in hdlc_open()
165 hdlc_proto_start(dev); in hdlc_open()
167 netdev_info(dev, "No carrier\n"); in hdlc_open()
178 void hdlc_close(struct net_device *dev) in hdlc_close() argument
180 hdlc_device *hdlc = dev_to_hdlc(dev); in hdlc_close()
182 printk(KERN_DEBUG "%s: hdlc_close() carrier %i open %i\n", dev->name, in hdlc_close()
190 hdlc_proto_stop(dev); in hdlc_close()
195 hdlc->proto->close(dev); in hdlc_close()
199 int hdlc_ioctl(struct net_device *dev, struct if_settings *ifs) in hdlc_ioctl() argument
204 if (dev_to_hdlc(dev)->proto) { in hdlc_ioctl()
205 result = dev_to_hdlc(dev)->proto->ioctl(dev, ifs); in hdlc_ioctl()
213 result = proto->ioctl(dev, ifs); in hdlc_ioctl()
224 static void hdlc_setup_dev(struct net_device *dev) in hdlc_setup_dev() argument
229 dev->flags = IFF_POINTOPOINT | IFF_NOARP; in hdlc_setup_dev()
230 dev->priv_flags = IFF_WAN_HDLC; in hdlc_setup_dev()
231 dev->mtu = HDLC_MAX_MTU; in hdlc_setup_dev()
232 dev->min_mtu = 68; in hdlc_setup_dev()
233 dev->max_mtu = HDLC_MAX_MTU; in hdlc_setup_dev()
234 dev->type = ARPHRD_RAWHDLC; in hdlc_setup_dev()
235 dev->hard_header_len = 0; in hdlc_setup_dev()
236 dev->needed_headroom = 0; in hdlc_setup_dev()
237 dev->addr_len = 0; in hdlc_setup_dev()
238 dev->header_ops = &hdlc_null_ops; in hdlc_setup_dev()
241 static void hdlc_setup(struct net_device *dev) in hdlc_setup() argument
243 hdlc_device *hdlc = dev_to_hdlc(dev); in hdlc_setup()
245 hdlc_setup_dev(dev); in hdlc_setup()
253 struct net_device *dev; in alloc_hdlcdev() local
255 dev = alloc_netdev(sizeof(struct hdlc_device), "hdlc%d", in alloc_hdlcdev()
257 if (dev) in alloc_hdlcdev()
258 dev_to_hdlc(dev)->priv = priv; in alloc_hdlcdev()
259 return dev; in alloc_hdlcdev()
263 void unregister_hdlc_device(struct net_device *dev) in unregister_hdlc_device() argument
266 detach_hdlc_protocol(dev); in unregister_hdlc_device()
267 unregister_netdevice(dev); in unregister_hdlc_device()
272 int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto, in attach_hdlc_protocol() argument
277 err = detach_hdlc_protocol(dev); in attach_hdlc_protocol()
285 dev_to_hdlc(dev)->state = kmalloc(size, GFP_KERNEL); in attach_hdlc_protocol()
286 if (!dev_to_hdlc(dev)->state) { in attach_hdlc_protocol()
291 dev_to_hdlc(dev)->proto = proto; in attach_hdlc_protocol()
297 int detach_hdlc_protocol(struct net_device *dev) in detach_hdlc_protocol() argument
299 hdlc_device *hdlc = dev_to_hdlc(dev); in detach_hdlc_protocol()
303 err = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev); in detach_hdlc_protocol()
306 netdev_err(dev, "Refused to change device type\n"); in detach_hdlc_protocol()
311 hdlc->proto->detach(dev); in detach_hdlc_protocol()
317 hdlc_setup_dev(dev); in detach_hdlc_protocol()