aboutsummaryrefslogtreecommitdiffstats
path: root/net/atm
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2012-05-10 16:17:00 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2012-05-15 20:14:35 -0400
commit60eea6cf2964beea6c38d9050bc3823a93db97e0 (patch)
tree46d62b637ca664a722d6ded6463299207b3b6723 /net/atm
parent1abd2296b4a1ee7b6a883541c3ede52042a09521 (diff)
atm: remove the coupling to token ring support
The token ring support is going away, so decouple the atm support from it in advance. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/atm')
-rw-r--r--net/atm/lec.c138
-rw-r--r--net/atm/lec.h1
2 files changed, 8 insertions, 131 deletions
diff --git a/net/atm/lec.c b/net/atm/lec.c
index bb35cb76b3af..a7d172105c99 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -26,11 +26,6 @@
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/seq_file.h> 27#include <linux/seq_file.h>
28 28
29/* TokenRing if needed */
30#ifdef CONFIG_TR
31#include <linux/trdevice.h>
32#endif
33
34/* And atm device */ 29/* And atm device */
35#include <linux/atmdev.h> 30#include <linux/atmdev.h>
36#include <linux/atmlec.h> 31#include <linux/atmlec.h>
@@ -163,50 +158,6 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
163#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ 158#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
164 159
165/* 160/*
166 * Modelled after tr_type_trans
167 * All multicast and ARE or STE frames go to BUS.
168 * Non source routed frames go by destination address.
169 * Last hop source routed frames go by destination address.
170 * Not last hop source routed frames go by _next_ route descriptor.
171 * Returns pointer to destination MAC address or fills in rdesc
172 * and returns NULL.
173 */
174#ifdef CONFIG_TR
175static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
176{
177 struct trh_hdr *trh;
178 unsigned int riflen, num_rdsc;
179
180 trh = (struct trh_hdr *)packet;
181 if (trh->daddr[0] & (uint8_t) 0x80)
182 return bus_mac; /* multicast */
183
184 if (trh->saddr[0] & TR_RII) {
185 riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8;
186 if ((ntohs(trh->rcf) >> 13) != 0)
187 return bus_mac; /* ARE or STE */
188 } else
189 return trh->daddr; /* not source routed */
190
191 if (riflen < 6)
192 return trh->daddr; /* last hop, source routed */
193
194 /* riflen is 6 or more, packet has more than one route descriptor */
195 num_rdsc = (riflen / 2) - 1;
196 memset(rdesc, 0, ETH_ALEN);
197 /* offset 4 comes from LAN destination field in LE control frames */
198 if (trh->rcf & htons((uint16_t) TR_RCF_DIR_BIT))
199 memcpy(&rdesc[4], &trh->rseg[num_rdsc - 2], sizeof(__be16));
200 else {
201 memcpy(&rdesc[4], &trh->rseg[1], sizeof(__be16));
202 rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0));
203 }
204
205 return NULL;
206}
207#endif /* CONFIG_TR */
208
209/*
210 * Open/initialize the netdevice. This is called (in the current kernel) 161 * Open/initialize the netdevice. This is called (in the current kernel)
211 * sometime after booting when the 'ifconfig' program is run. 162 * sometime after booting when the 'ifconfig' program is run.
212 * 163 *
@@ -257,9 +208,6 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
257 struct lec_arp_table *entry; 208 struct lec_arp_table *entry;
258 unsigned char *dst; 209 unsigned char *dst;
259 int min_frame_size; 210 int min_frame_size;
260#ifdef CONFIG_TR
261 unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */
262#endif
263 int is_rdesc; 211 int is_rdesc;
264 212
265 pr_debug("called\n"); 213 pr_debug("called\n");
@@ -290,24 +238,10 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
290 } 238 }
291 skb_push(skb, 2); 239 skb_push(skb, 2);
292 240
293 /* Put le header to place, works for TokenRing too */ 241 /* Put le header to place */
294 lec_h = (struct lecdatahdr_8023 *)skb->data; 242 lec_h = (struct lecdatahdr_8023 *)skb->data;
295 lec_h->le_header = htons(priv->lecid); 243 lec_h->le_header = htons(priv->lecid);
296 244
297#ifdef CONFIG_TR
298 /*
299 * Ugly. Use this to realign Token Ring packets for
300 * e.g. PCA-200E driver.
301 */
302 if (priv->is_trdev) {
303 skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
304 kfree_skb(skb);
305 if (skb2 == NULL)
306 return NETDEV_TX_OK;
307 skb = skb2;
308 }
309#endif
310
311#if DUMP_PACKETS >= 2 245#if DUMP_PACKETS >= 2
312#define MAX_DUMP_SKB 99 246#define MAX_DUMP_SKB 99
313#elif DUMP_PACKETS >= 1 247#elif DUMP_PACKETS >= 1
@@ -321,12 +255,7 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
321#endif /* DUMP_PACKETS >= 1 */ 255#endif /* DUMP_PACKETS >= 1 */
322 256
323 /* Minimum ethernet-frame size */ 257 /* Minimum ethernet-frame size */
324#ifdef CONFIG_TR 258 min_frame_size = LEC_MINIMUM_8023_SIZE;
325 if (priv->is_trdev)
326 min_frame_size = LEC_MINIMUM_8025_SIZE;
327 else
328#endif
329 min_frame_size = LEC_MINIMUM_8023_SIZE;
330 if (skb->len < min_frame_size) { 259 if (skb->len < min_frame_size) {
331 if ((skb->len + skb_tailroom(skb)) < min_frame_size) { 260 if ((skb->len + skb_tailroom(skb)) < min_frame_size) {
332 skb2 = skb_copy_expand(skb, 0, 261 skb2 = skb_copy_expand(skb, 0,
@@ -345,15 +274,6 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
345 /* Send to right vcc */ 274 /* Send to right vcc */
346 is_rdesc = 0; 275 is_rdesc = 0;
347 dst = lec_h->h_dest; 276 dst = lec_h->h_dest;
348#ifdef CONFIG_TR
349 if (priv->is_trdev) {
350 dst = get_tr_dst(skb->data + 2, rdesc);
351 if (dst == NULL) {
352 dst = rdesc;
353 is_rdesc = 1;
354 }
355 }
356#endif
357 entry = NULL; 277 entry = NULL;
358 vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); 278 vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry);
359 pr_debug("%s:vcc:%p vcc_flags:%lx, entry:%p\n", 279 pr_debug("%s:vcc:%p vcc_flags:%lx, entry:%p\n",
@@ -710,12 +630,7 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
710 dev_kfree_skb(skb); 630 dev_kfree_skb(skb);
711 return; 631 return;
712 } 632 }
713#ifdef CONFIG_TR 633 dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest;
714 if (priv->is_trdev)
715 dst = ((struct lecdatahdr_8025 *)skb->data)->h_dest;
716 else
717#endif
718 dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest;
719 634
720 /* 635 /*
721 * If this is a Data Direct VCC, and the VCC does not match 636 * If this is a Data Direct VCC, and the VCC does not match
@@ -723,16 +638,7 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
723 */ 638 */
724 spin_lock_irqsave(&priv->lec_arp_lock, flags); 639 spin_lock_irqsave(&priv->lec_arp_lock, flags);
725 if (lec_is_data_direct(vcc)) { 640 if (lec_is_data_direct(vcc)) {
726#ifdef CONFIG_TR 641 src = ((struct lecdatahdr_8023 *)skb->data)->h_source;
727 if (priv->is_trdev)
728 src =
729 ((struct lecdatahdr_8025 *)skb->data)->
730 h_source;
731 else
732#endif
733 src =
734 ((struct lecdatahdr_8023 *)skb->data)->
735 h_source;
736 entry = lec_arp_find(priv, src); 642 entry = lec_arp_find(priv, src);
737 if (entry && entry->vcc != vcc) { 643 if (entry && entry->vcc != vcc) {
738 lec_arp_remove(priv, entry); 644 lec_arp_remove(priv, entry);
@@ -750,12 +656,7 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
750 if (!hlist_empty(&priv->lec_arp_empty_ones)) 656 if (!hlist_empty(&priv->lec_arp_empty_ones))
751 lec_arp_check_empties(priv, vcc, skb); 657 lec_arp_check_empties(priv, vcc, skb);
752 skb_pull(skb, 2); /* skip lec_id */ 658 skb_pull(skb, 2); /* skip lec_id */
753#ifdef CONFIG_TR 659 skb->protocol = eth_type_trans(skb, dev);
754 if (priv->is_trdev)
755 skb->protocol = tr_type_trans(skb, dev);
756 else
757#endif
758 skb->protocol = eth_type_trans(skb, dev);
759 dev->stats.rx_packets++; 660 dev->stats.rx_packets++;
760 dev->stats.rx_bytes += skb->len; 661 dev->stats.rx_bytes += skb->len;
761 memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data)); 662 memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
@@ -827,27 +728,13 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
827 i = 0; 728 i = 0;
828 else 729 else
829 i = arg; 730 i = arg;
830#ifdef CONFIG_TR
831 if (arg >= MAX_LEC_ITF) 731 if (arg >= MAX_LEC_ITF)
832 return -EINVAL; 732 return -EINVAL;
833#else /* Reserve the top NUM_TR_DEVS for TR */
834 if (arg >= (MAX_LEC_ITF - NUM_TR_DEVS))
835 return -EINVAL;
836#endif
837 if (!dev_lec[i]) { 733 if (!dev_lec[i]) {
838 int is_trdev, size; 734 int size;
839
840 is_trdev = 0;
841 if (i >= (MAX_LEC_ITF - NUM_TR_DEVS))
842 is_trdev = 1;
843 735
844 size = sizeof(struct lec_priv); 736 size = sizeof(struct lec_priv);
845#ifdef CONFIG_TR 737 dev_lec[i] = alloc_etherdev(size);
846 if (is_trdev)
847 dev_lec[i] = alloc_trdev(size);
848 else
849#endif
850 dev_lec[i] = alloc_etherdev(size);
851 if (!dev_lec[i]) 738 if (!dev_lec[i])
852 return -ENOMEM; 739 return -ENOMEM;
853 dev_lec[i]->netdev_ops = &lec_netdev_ops; 740 dev_lec[i]->netdev_ops = &lec_netdev_ops;
@@ -858,7 +745,6 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
858 } 745 }
859 746
860 priv = netdev_priv(dev_lec[i]); 747 priv = netdev_priv(dev_lec[i]);
861 priv->is_trdev = is_trdev;
862 } else { 748 } else {
863 priv = netdev_priv(dev_lec[i]); 749 priv = netdev_priv(dev_lec[i]);
864 if (priv->lecd) 750 if (priv->lecd)
@@ -2372,15 +2258,7 @@ lec_arp_check_empties(struct lec_priv *priv,
2372 struct hlist_node *node, *next; 2258 struct hlist_node *node, *next;
2373 struct lec_arp_table *entry, *tmp; 2259 struct lec_arp_table *entry, *tmp;
2374 struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data; 2260 struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data;
2375 unsigned char *src; 2261 unsigned char *src = hdr->h_source;
2376#ifdef CONFIG_TR
2377 struct lecdatahdr_8025 *tr_hdr = (struct lecdatahdr_8025 *)skb->data;
2378
2379 if (priv->is_trdev)
2380 src = tr_hdr->h_source;
2381 else
2382#endif
2383 src = hdr->h_source;
2384 2262
2385 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2263 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2386 hlist_for_each_entry_safe(entry, node, next, 2264 hlist_for_each_entry_safe(entry, node, next,
diff --git a/net/atm/lec.h b/net/atm/lec.h
index dfc071966463..c730e57de199 100644
--- a/net/atm/lec.h
+++ b/net/atm/lec.h
@@ -142,7 +142,6 @@ struct lec_priv {
142 int itfnum; /* e.g. 2 for lec2, 5 for lec5 */ 142 int itfnum; /* e.g. 2 for lec2, 5 for lec5 */
143 struct lane2_ops *lane2_ops; /* can be NULL for LANE v1 */ 143 struct lane2_ops *lane2_ops; /* can be NULL for LANE v1 */
144 int is_proxy; /* bridge between ATM and Ethernet */ 144 int is_proxy; /* bridge between ATM and Ethernet */
145 int is_trdev; /* Device type, 0 = Ethernet, 1 = TokenRing */
146}; 145};
147 146
148struct lec_vcc_priv { 147struct lec_vcc_priv {