diff options
Diffstat (limited to 'net/atm/br2684.c')
-rw-r--r-- | net/atm/br2684.c | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/net/atm/br2684.c b/net/atm/br2684.c index ea9438fc6855..334fcd4a4ea4 100644 --- a/net/atm/br2684.c +++ b/net/atm/br2684.c | |||
@@ -83,7 +83,6 @@ struct br2684_dev { | |||
83 | struct list_head br2684_devs; | 83 | struct list_head br2684_devs; |
84 | int number; | 84 | int number; |
85 | struct list_head brvccs; /* one device <=> one vcc (before xmas) */ | 85 | struct list_head brvccs; /* one device <=> one vcc (before xmas) */ |
86 | struct net_device_stats stats; | ||
87 | int mac_was_set; | 86 | int mac_was_set; |
88 | enum br2684_payload payload; | 87 | enum br2684_payload payload; |
89 | }; | 88 | }; |
@@ -148,9 +147,10 @@ static struct net_device *br2684_find_dev(const struct br2684_if_spec *s) | |||
148 | * the way for multiple vcc's per itf. Returns true if we can send, | 147 | * the way for multiple vcc's per itf. Returns true if we can send, |
149 | * otherwise false | 148 | * otherwise false |
150 | */ | 149 | */ |
151 | static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev, | 150 | static int br2684_xmit_vcc(struct sk_buff *skb, struct net_device *dev, |
152 | struct br2684_vcc *brvcc) | 151 | struct br2684_vcc *brvcc) |
153 | { | 152 | { |
153 | struct br2684_dev *brdev = BRPRIV(dev); | ||
154 | struct atm_vcc *atmvcc; | 154 | struct atm_vcc *atmvcc; |
155 | int minheadroom = (brvcc->encaps == e_llc) ? 10 : 2; | 155 | int minheadroom = (brvcc->encaps == e_llc) ? 10 : 2; |
156 | 156 | ||
@@ -211,8 +211,8 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev, | |||
211 | } | 211 | } |
212 | atomic_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc); | 212 | atomic_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc); |
213 | ATM_SKB(skb)->atm_options = atmvcc->atm_options; | 213 | ATM_SKB(skb)->atm_options = atmvcc->atm_options; |
214 | brdev->stats.tx_packets++; | 214 | dev->stats.tx_packets++; |
215 | brdev->stats.tx_bytes += skb->len; | 215 | dev->stats.tx_bytes += skb->len; |
216 | atmvcc->send(atmvcc, skb); | 216 | atmvcc->send(atmvcc, skb); |
217 | return 1; | 217 | return 1; |
218 | } | 218 | } |
@@ -233,14 +233,14 @@ static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
233 | brvcc = pick_outgoing_vcc(skb, brdev); | 233 | brvcc = pick_outgoing_vcc(skb, brdev); |
234 | if (brvcc == NULL) { | 234 | if (brvcc == NULL) { |
235 | pr_debug("no vcc attached to dev %s\n", dev->name); | 235 | pr_debug("no vcc attached to dev %s\n", dev->name); |
236 | brdev->stats.tx_errors++; | 236 | dev->stats.tx_errors++; |
237 | brdev->stats.tx_carrier_errors++; | 237 | dev->stats.tx_carrier_errors++; |
238 | /* netif_stop_queue(dev); */ | 238 | /* netif_stop_queue(dev); */ |
239 | dev_kfree_skb(skb); | 239 | dev_kfree_skb(skb); |
240 | read_unlock(&devs_lock); | 240 | read_unlock(&devs_lock); |
241 | return 0; | 241 | return 0; |
242 | } | 242 | } |
243 | if (!br2684_xmit_vcc(skb, brdev, brvcc)) { | 243 | if (!br2684_xmit_vcc(skb, dev, brvcc)) { |
244 | /* | 244 | /* |
245 | * We should probably use netif_*_queue() here, but that | 245 | * We should probably use netif_*_queue() here, but that |
246 | * involves added complication. We need to walk before | 246 | * involves added complication. We need to walk before |
@@ -248,27 +248,20 @@ static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
248 | * | 248 | * |
249 | * Don't free here! this pointer might be no longer valid! | 249 | * Don't free here! this pointer might be no longer valid! |
250 | */ | 250 | */ |
251 | brdev->stats.tx_errors++; | 251 | dev->stats.tx_errors++; |
252 | brdev->stats.tx_fifo_errors++; | 252 | dev->stats.tx_fifo_errors++; |
253 | } | 253 | } |
254 | read_unlock(&devs_lock); | 254 | read_unlock(&devs_lock); |
255 | return 0; | 255 | return 0; |
256 | } | 256 | } |
257 | 257 | ||
258 | static struct net_device_stats *br2684_get_stats(struct net_device *dev) | ||
259 | { | ||
260 | pr_debug("br2684_get_stats\n"); | ||
261 | return &BRPRIV(dev)->stats; | ||
262 | } | ||
263 | |||
264 | /* | 258 | /* |
265 | * We remember when the MAC gets set, so we don't override it later with | 259 | * We remember when the MAC gets set, so we don't override it later with |
266 | * the ESI of the ATM card of the first VC | 260 | * the ESI of the ATM card of the first VC |
267 | */ | 261 | */ |
268 | static int (*my_eth_mac_addr) (struct net_device *, void *); | ||
269 | static int br2684_mac_addr(struct net_device *dev, void *p) | 262 | static int br2684_mac_addr(struct net_device *dev, void *p) |
270 | { | 263 | { |
271 | int err = my_eth_mac_addr(dev, p); | 264 | int err = eth_mac_addr(dev, p); |
272 | if (!err) | 265 | if (!err) |
273 | BRPRIV(dev)->mac_was_set = 1; | 266 | BRPRIV(dev)->mac_was_set = 1; |
274 | return err; | 267 | return err; |
@@ -430,17 +423,17 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb) | |||
430 | /* sigh, interface is down? */ | 423 | /* sigh, interface is down? */ |
431 | if (unlikely(!(net_dev->flags & IFF_UP))) | 424 | if (unlikely(!(net_dev->flags & IFF_UP))) |
432 | goto dropped; | 425 | goto dropped; |
433 | brdev->stats.rx_packets++; | 426 | net_dev->stats.rx_packets++; |
434 | brdev->stats.rx_bytes += skb->len; | 427 | net_dev->stats.rx_bytes += skb->len; |
435 | memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data)); | 428 | memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data)); |
436 | netif_rx(skb); | 429 | netif_rx(skb); |
437 | return; | 430 | return; |
438 | 431 | ||
439 | dropped: | 432 | dropped: |
440 | brdev->stats.rx_dropped++; | 433 | net_dev->stats.rx_dropped++; |
441 | goto free_skb; | 434 | goto free_skb; |
442 | error: | 435 | error: |
443 | brdev->stats.rx_errors++; | 436 | net_dev->stats.rx_errors++; |
444 | free_skb: | 437 | free_skb: |
445 | dev_kfree_skb(skb); | 438 | dev_kfree_skb(skb); |
446 | return; | 439 | return; |
@@ -531,8 +524,8 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg) | |||
531 | 524 | ||
532 | skb->next = skb->prev = NULL; | 525 | skb->next = skb->prev = NULL; |
533 | br2684_push(atmvcc, skb); | 526 | br2684_push(atmvcc, skb); |
534 | BRPRIV(skb->dev)->stats.rx_bytes -= skb->len; | 527 | skb->dev->stats.rx_bytes -= skb->len; |
535 | BRPRIV(skb->dev)->stats.rx_packets--; | 528 | skb->dev->stats.rx_packets--; |
536 | 529 | ||
537 | skb = next; | 530 | skb = next; |
538 | } | 531 | } |
@@ -544,17 +537,20 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg) | |||
544 | return err; | 537 | return err; |
545 | } | 538 | } |
546 | 539 | ||
540 | static const struct net_device_ops br2684_netdev_ops = { | ||
541 | .ndo_start_xmit = br2684_start_xmit, | ||
542 | .ndo_set_mac_address = br2684_mac_addr, | ||
543 | .ndo_change_mtu = eth_change_mtu, | ||
544 | .ndo_validate_addr = eth_validate_addr, | ||
545 | }; | ||
546 | |||
547 | static void br2684_setup(struct net_device *netdev) | 547 | static void br2684_setup(struct net_device *netdev) |
548 | { | 548 | { |
549 | struct br2684_dev *brdev = BRPRIV(netdev); | 549 | struct br2684_dev *brdev = BRPRIV(netdev); |
550 | 550 | ||
551 | ether_setup(netdev); | 551 | ether_setup(netdev); |
552 | brdev->net_dev = netdev; | ||
553 | 552 | ||
554 | my_eth_mac_addr = netdev->set_mac_address; | 553 | netdev->netdev_ops = &br2684_netdev_ops; |
555 | netdev->set_mac_address = br2684_mac_addr; | ||
556 | netdev->hard_start_xmit = br2684_start_xmit; | ||
557 | netdev->get_stats = br2684_get_stats; | ||
558 | 554 | ||
559 | INIT_LIST_HEAD(&brdev->brvccs); | 555 | INIT_LIST_HEAD(&brdev->brvccs); |
560 | } | 556 | } |
@@ -565,10 +561,8 @@ static void br2684_setup_routed(struct net_device *netdev) | |||
565 | brdev->net_dev = netdev; | 561 | brdev->net_dev = netdev; |
566 | 562 | ||
567 | netdev->hard_header_len = 0; | 563 | netdev->hard_header_len = 0; |
568 | my_eth_mac_addr = netdev->set_mac_address; | 564 | |
569 | netdev->set_mac_address = br2684_mac_addr; | 565 | netdev->netdev_ops = &br2684_netdev_ops; |
570 | netdev->hard_start_xmit = br2684_start_xmit; | ||
571 | netdev->get_stats = br2684_get_stats; | ||
572 | netdev->addr_len = 0; | 566 | netdev->addr_len = 0; |
573 | netdev->mtu = 1500; | 567 | netdev->mtu = 1500; |
574 | netdev->type = ARPHRD_PPP; | 568 | netdev->type = ARPHRD_PPP; |