Commit d44f7746 authored by Chas Williams's avatar Chas Williams Committed by David S. Miller

[ATM]: [lec] indent, comment and whitespace cleanup

Signed-off-by: default avatarChas Williams <chas@cmf.nrl.navy.mil>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f236218b
/*
* lec.c: Lan Emulation driver
* Marko Kiiskila mkiiskila@yahoo.com
*
* Marko Kiiskila <mkiiskila@yahoo.com>
*/
#include <linux/kernel.h>
......@@ -38,7 +38,7 @@
#include <linux/if_bridge.h>
#include "../bridge/br_private.h"
static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00};
static unsigned char bridge_ula_lec[] = { 0x01, 0x80, 0xc2, 0x00, 0x00 };
#endif
/* Modular too */
......@@ -55,29 +55,32 @@ static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00};
#define DPRINTK(format,args...)
#endif
#define DUMP_PACKETS 0 /* 0 = None,
#define DUMP_PACKETS 0 /*
* 0 = None,
* 1 = 30 first bytes
* 2 = Whole packet
*/
#define LEC_UNRES_QUE_LEN 8 /* number of tx packets to queue for a
single destination while waiting for SVC */
#define LEC_UNRES_QUE_LEN 8 /*
* number of tx packets to queue for a
* single destination while waiting for SVC
*/
static int lec_open(struct net_device *dev);
static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev);
static int lec_close(struct net_device *dev);
static struct net_device_stats *lec_get_stats(struct net_device *dev);
static void lec_init(struct net_device *dev);
static struct lec_arp_table* lec_arp_find(struct lec_priv *priv,
static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
unsigned char *mac_addr);
static int lec_arp_remove(struct lec_priv *priv,
struct lec_arp_table *to_remove);
/* LANE2 functions */
static void lane2_associate_ind (struct net_device *dev, u8 *mac_address,
static void lane2_associate_ind(struct net_device *dev, u8 *mac_address,
u8 *tlvs, u32 sizeoftlvs);
static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
u8 **tlvs, u32 *sizeoftlvs);
static int lane2_associate_req (struct net_device *dev, u8 *lan_dst,
static int lane2_associate_req(struct net_device *dev, u8 *lan_dst,
u8 *tlvs, u32 sizeoftlvs);
static int lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr,
......@@ -86,7 +89,7 @@ static void lec_arp_check_empties(struct lec_priv *priv,
struct atm_vcc *vcc, struct sk_buff *skb);
static void lec_arp_destroy(struct lec_priv *priv);
static void lec_arp_init(struct lec_priv *priv);
static struct atm_vcc* lec_arp_resolve(struct lec_priv *priv,
static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
unsigned char *mac_to_find,
int is_rdesc,
struct lec_arp_table **ret_entry);
......@@ -100,7 +103,8 @@ static void lec_set_flush_tran_id(struct lec_priv *priv,
unsigned long tran_id);
static void lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
struct atm_vcc *vcc,
void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb));
void (*old_push) (struct atm_vcc *vcc,
struct sk_buff *skb));
static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc);
static struct lane2_ops lane2_ops = {
......@@ -109,7 +113,7 @@ static struct lane2_ops lane2_ops = {
NULL /* associate indicator, spec 3.1.5 */
};
static unsigned char bus_mac[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
/* Device structures */
static struct net_device *dev_lec[MAX_LEC_ITF];
......@@ -121,9 +125,11 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
char *buff;
struct lec_priv *priv;
/* Check if this is a BPDU. If so, ask zeppelin to send
/*
* Check if this is a BPDU. If so, ask zeppelin to send
* LE_TOPOLOGY_REQUEST with the same value of Topology Change bit
* as the Config BPDU has */
* as the Config BPDU has
*/
eth = (struct ethhdr *)skb->data;
buff = skb->data + skb->dev->hard_header_len;
if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) {
......@@ -132,7 +138,8 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
struct atmlec_msg *mesg;
skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
if (skb2 == NULL) return;
if (skb2 == NULL)
return;
skb2->len = sizeof(struct atmlec_msg);
mesg = (struct atmlec_msg *)skb2->data;
mesg->type = l_topology_change;
......@@ -166,26 +173,25 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
int riflen, num_rdsc;
trh = (struct trh_hdr *)packet;
if (trh->daddr[0] & (uint8_t)0x80)
if (trh->daddr[0] & (uint8_t) 0x80)
return bus_mac; /* multicast */
if (trh->saddr[0] & TR_RII) {
riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8;
if ((ntohs(trh->rcf) >> 13) != 0)
return bus_mac; /* ARE or STE */
}
else
} else
return trh->daddr; /* not source routed */
if (riflen < 6)
return trh->daddr; /* last hop, source routed */
/* riflen is 6 or more, packet has more than one route descriptor */
num_rdsc = (riflen/2) - 1;
num_rdsc = (riflen / 2) - 1;
memset(rdesc, 0, ETH_ALEN);
/* offset 4 comes from LAN destination field in LE control frames */
if (trh->rcf & htons((uint16_t)TR_RCF_DIR_BIT))
memcpy(&rdesc[4], &trh->rseg[num_rdsc-2], sizeof(uint16_t));
if (trh->rcf & htons((uint16_t) TR_RCF_DIR_BIT))
memcpy(&rdesc[4], &trh->rseg[num_rdsc - 2], sizeof(uint16_t));
else {
memcpy(&rdesc[4], &trh->rseg[1], sizeof(uint16_t));
rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0));
......@@ -204,13 +210,12 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
* there is non-reboot way to recover if something goes wrong.
*/
static int
lec_open(struct net_device *dev)
static int lec_open(struct net_device *dev)
{
struct lec_priv *priv = (struct lec_priv *)dev->priv;
netif_start_queue(dev);
memset(&priv->stats,0,sizeof(struct net_device_stats));
memset(&priv->stats, 0, sizeof(struct net_device_stats));
return 0;
}
......@@ -231,16 +236,14 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb, struct lec_priv *priv)
priv->stats.tx_bytes += skb->len;
}
static void
lec_tx_timeout(struct net_device *dev)
static void lec_tx_timeout(struct net_device *dev)
{
printk(KERN_INFO "%s: tx timeout\n", dev->name);
dev->trans_start = jiffies;
netif_wake_queue(dev);
}
static int
lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct sk_buff *skb2;
struct lec_priv *priv = (struct lec_priv *)dev->priv;
......@@ -255,12 +258,12 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
int is_rdesc;
#if DUMP_PACKETS > 0
char buf[300];
int i=0;
int i = 0;
#endif /* DUMP_PACKETS >0 */
DPRINTK("lec_start_xmit called\n");
if (!priv->lecd) {
printk("%s:No lecd attached\n",dev->name);
printk("%s:No lecd attached\n", dev->name);
priv->stats.tx_errors++;
netif_stop_queue(dev);
return -EUNATCH;
......@@ -280,22 +283,26 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
DPRINTK("lec_start_xmit: reallocating skb\n");
skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
kfree_skb(skb);
if (skb2 == NULL) return 0;
if (skb2 == NULL)
return 0;
skb = skb2;
}
skb_push(skb, 2);
/* Put le header to place, works for TokenRing too */
lec_h = (struct lecdatahdr_8023*)skb->data;
lec_h = (struct lecdatahdr_8023 *)skb->data;
lec_h->le_header = htons(priv->lecid);
#ifdef CONFIG_TR
/* Ugly. Use this to realign Token Ring packets for
* e.g. PCA-200E driver. */
/*
* Ugly. Use this to realign Token Ring packets for
* e.g. PCA-200E driver.
*/
if (priv->is_trdev) {
skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
kfree_skb(skb);
if (skb2 == NULL) return 0;
if (skb2 == NULL)
return 0;
skb = skb2;
}
#endif
......@@ -304,18 +311,18 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name,
skb->len, priv->lecid);
#if DUMP_PACKETS >= 2
for(i=0;i<skb->len && i <99;i++) {
sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]);
for (i = 0; i < skb->len && i < 99; i++) {
sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
}
#elif DUMP_PACKETS >= 1
for(i=0;i<skb->len && i < 30;i++) {
sprintf(buf+i*3,"%2.2x ", 0xff&skb->data[i]);
for (i = 0; i < skb->len && i < 30; i++) {
sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
}
#endif /* DUMP_PACKETS >= 1 */
if (i==skb->len)
printk("%s\n",buf);
if (i == skb->len)
printk("%s\n", buf);
else
printk("%s...\n",buf);
printk("%s...\n", buf);
#endif /* DUMP_PACKETS > 0 */
/* Minimum ethernet-frame size */
......@@ -328,7 +335,8 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (skb->len < min_frame_size) {
if ((skb->len + skb_tailroom(skb)) < min_frame_size) {
skb2 = skb_copy_expand(skb, 0,
min_frame_size - skb->truesize, GFP_ATOMIC);
min_frame_size - skb->truesize,
GFP_ATOMIC);
dev_kfree_skb(skb);
if (skb2 == NULL) {
priv->stats.tx_dropped++;
......@@ -344,7 +352,7 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
dst = lec_h->h_dest;
#ifdef CONFIG_TR
if (priv->is_trdev) {
dst = get_tr_dst(skb->data+2, rdesc);
dst = get_tr_dst(skb->data + 2, rdesc);
if (dst == NULL) {
dst = rdesc;
is_rdesc = 1;
......@@ -354,28 +362,31 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
entry = NULL;
vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry);
DPRINTK("%s:vcc:%p vcc_flags:%x, entry:%p\n", dev->name,
vcc, vcc?vcc->flags:0, entry);
if (!vcc || !test_bit(ATM_VF_READY,&vcc->flags)) {
vcc, vcc ? vcc->flags : 0, entry);
if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) {
if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) {
DPRINTK("%s:lec_start_xmit: queuing packet, ", dev->name);
DPRINTK("%s:lec_start_xmit: queuing packet, ",
dev->name);
DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2],
lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]);
lec_h->h_dest[0], lec_h->h_dest[1],
lec_h->h_dest[2], lec_h->h_dest[3],
lec_h->h_dest[4], lec_h->h_dest[5]);
skb_queue_tail(&entry->tx_wait, skb);
} else {
DPRINTK("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", dev->name);
DPRINTK
("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ",
dev->name);
DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2],
lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]);
lec_h->h_dest[0], lec_h->h_dest[1],
lec_h->h_dest[2], lec_h->h_dest[3],
lec_h->h_dest[4], lec_h->h_dest[5]);
priv->stats.tx_dropped++;
dev_kfree_skb(skb);
}
return 0;
}
#if DUMP_PACKETS > 0
printk("%s:sending to vpi:%d vci:%d\n", dev->name,
vcc->vpi, vcc->vci);
printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci);
#endif /* DUMP_PACKETS > 0 */
while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) {
......@@ -409,8 +420,7 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
}
/* The inverse routine to net_open(). */
static int
lec_close(struct net_device *dev)
static int lec_close(struct net_device *dev)
{
netif_stop_queue(dev);
return 0;
......@@ -420,18 +430,16 @@ lec_close(struct net_device *dev)
* Get the current statistics.
* This may be called with the card open or closed.
*/
static struct net_device_stats *
lec_get_stats(struct net_device *dev)
static struct net_device_stats *lec_get_stats(struct net_device *dev)
{
return &((struct lec_priv *)dev->priv)->stats;
}
static int
lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
{
unsigned long flags;
struct net_device *dev = (struct net_device*)vcc->proto_data;
struct lec_priv *priv = (struct lec_priv*)dev->priv;
struct net_device *dev = (struct net_device *)vcc->proto_data;
struct lec_priv *priv = (struct lec_priv *)dev->priv;
struct atmlec_msg *mesg;
struct lec_arp_table *entry;
int i;
......@@ -442,14 +450,14 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
tmp = skb->data;
tmp += sizeof(struct atmlec_msg);
DPRINTK("%s: msg from zeppelin:%d\n", dev->name, mesg->type);
switch(mesg->type) {
switch (mesg->type) {
case l_set_mac_addr:
for (i=0;i<6;i++) {
for (i = 0; i < 6; i++) {
dev->dev_addr[i] = mesg->content.normal.mac_addr[i];
}
break;
case l_del_mac_addr:
for(i=0;i<6;i++) {
for (i = 0; i < 6; i++) {
dev->dev_addr[i] = 0;
}
break;
......@@ -479,9 +487,9 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
mesg->content.normal.targetless_le_arp);
DPRINTK("lec: in l_arp_update\n");
if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */
DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", mesg->sizeoftlvs);
lane2_associate_ind(dev,
mesg->content.normal.mac_addr,
DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n",
mesg->sizeoftlvs);
lane2_associate_ind(dev, mesg->content.normal.mac_addr,
tmp, mesg->sizeoftlvs);
}
break;
......@@ -489,17 +497,16 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
priv->maximum_unknown_frame_count =
mesg->content.config.maximum_unknown_frame_count;
priv->max_unknown_frame_time =
(mesg->content.config.max_unknown_frame_time*HZ);
priv->max_retry_count =
mesg->content.config.max_retry_count;
priv->aging_time = (mesg->content.config.aging_time*HZ);
(mesg->content.config.max_unknown_frame_time * HZ);
priv->max_retry_count = mesg->content.config.max_retry_count;
priv->aging_time = (mesg->content.config.aging_time * HZ);
priv->forward_delay_time =
(mesg->content.config.forward_delay_time*HZ);
(mesg->content.config.forward_delay_time * HZ);
priv->arp_response_time =
(mesg->content.config.arp_response_time*HZ);
priv->flush_timeout = (mesg->content.config.flush_timeout*HZ);
(mesg->content.config.arp_response_time * HZ);
priv->flush_timeout = (mesg->content.config.flush_timeout * HZ);
priv->path_switching_delay =
(mesg->content.config.path_switching_delay*HZ);
(mesg->content.config.path_switching_delay * HZ);
priv->lane_version = mesg->content.config.lane_version; /* LANE2 */
priv->lane2_ops = NULL;
if (priv->lane_version > 1)
......@@ -514,45 +521,56 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
mesg->content.normal.flag);
break;
case l_set_lecid:
priv->lecid=(unsigned short)(0xffff&mesg->content.normal.flag);
priv->lecid =
(unsigned short)(0xffff & mesg->content.normal.flag);
break;
case l_should_bridge: {
case l_should_bridge:
#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
{
struct net_bridge_fdb_entry *f;
DPRINTK("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
dev->name,
mesg->content.proxy.mac_addr[0], mesg->content.proxy.mac_addr[1],
mesg->content.proxy.mac_addr[2], mesg->content.proxy.mac_addr[3],
mesg->content.proxy.mac_addr[4], mesg->content.proxy.mac_addr[5]);
DPRINTK
("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
dev->name, mesg->content.proxy.mac_addr[0],
mesg->content.proxy.mac_addr[1],
mesg->content.proxy.mac_addr[2],
mesg->content.proxy.mac_addr[3],
mesg->content.proxy.mac_addr[4],
mesg->content.proxy.mac_addr[5]);
if (br_fdb_get_hook == NULL || dev->br_port == NULL)
break;
f = br_fdb_get_hook(dev->br_port->br, mesg->content.proxy.mac_addr);
if (f != NULL &&
f->dst->dev != dev &&
f->dst->state == BR_STATE_FORWARDING) {
f = br_fdb_get_hook(dev->br_port->br,
mesg->content.proxy.mac_addr);
if (f != NULL && f->dst->dev != dev
&& f->dst->state == BR_STATE_FORWARDING) {
/* hit from bridge table, send LE_ARP_RESPONSE */
struct sk_buff *skb2;
struct sock *sk;
DPRINTK("%s: entry found, responding to zeppelin\n", dev->name);
skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
DPRINTK
("%s: entry found, responding to zeppelin\n",
dev->name);
skb2 =
alloc_skb(sizeof(struct atmlec_msg),
GFP_ATOMIC);
if (skb2 == NULL) {
br_fdb_put_hook(f);
break;
}
skb2->len = sizeof(struct atmlec_msg);
memcpy(skb2->data, mesg, sizeof(struct atmlec_msg));
memcpy(skb2->data, mesg,
sizeof(struct atmlec_msg));
atm_force_charge(priv->lecd, skb2->truesize);
sk = sk_atm(priv->lecd);
skb_queue_tail(&sk->sk_receive_queue, skb2);
sk->sk_data_ready(sk, skb2->len);
}
if (f != NULL) br_fdb_put_hook(f);
#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
if (f != NULL)
br_fdb_put_hook(f);
}
#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
break;
default:
printk("%s: Unknown message type %d\n", dev->name, mesg->type);
......@@ -563,8 +581,7 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
return 0;
}
static void
lec_atm_close(struct atm_vcc *vcc)
static void lec_atm_close(struct atm_vcc *vcc)
{
struct sk_buff *skb;
struct net_device *dev = (struct net_device *)vcc->proto_data;
......@@ -658,14 +675,14 @@ static int lec_change_mtu(struct net_device *dev, int new_mtu)
static void lec_set_multicast_list(struct net_device *dev)
{
/* by default, all multicast frames arrive over the bus.
/*
* by default, all multicast frames arrive over the bus.
* eventually support selective multicast service
*/
return;
}
static void
lec_init(struct net_device *dev)
static void lec_init(struct net_device *dev)
{
dev->change_mtu = lec_change_mtu;
dev->open = lec_open;
......@@ -676,7 +693,7 @@ lec_init(struct net_device *dev)
dev->get_stats = lec_get_stats;
dev->set_multicast_list = lec_set_multicast_list;
dev->do_ioctl = NULL;
printk("%s: Initialized!\n",dev->name);
printk("%s: Initialized!\n", dev->name);
return;
}
......@@ -684,7 +701,8 @@ static unsigned char lec_ctrl_magic[] = {
0xff,
0x00,
0x01,
0x01 };
0x01
};
#define LEC_DATA_DIRECT_8023 2
#define LEC_DATA_DIRECT_8025 3
......@@ -695,22 +713,21 @@ static int lec_is_data_direct(struct atm_vcc *vcc)
(vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025));
}
static void
lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
{
unsigned long flags;
struct net_device *dev = (struct net_device *)vcc->proto_data;
struct lec_priv *priv = (struct lec_priv *)dev->priv;
#if DUMP_PACKETS >0
int i=0;
int i = 0;
char buf[300];
printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name,
vcc->vpi, vcc->vci);
#endif
if (!skb) {
DPRINTK("%s: null skb\n",dev->name);
DPRINTK("%s: null skb\n", dev->name);
lec_vcc_close(priv, vcc);
return;
}
......@@ -718,57 +735,63 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name,
skb->len, priv->lecid);
#if DUMP_PACKETS >= 2
for(i=0;i<skb->len && i <99;i++) {
sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]);
for (i = 0; i < skb->len && i < 99; i++) {
sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
}
#elif DUMP_PACKETS >= 1
for(i=0;i<skb->len && i < 30;i++) {
sprintf(buf+i*3,"%2.2x ", 0xff&skb->data[i]);
for (i = 0; i < skb->len && i < 30; i++) {
sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
}
#endif /* DUMP_PACKETS >= 1 */
if (i==skb->len)
printk("%s\n",buf);
if (i == skb->len)
printk("%s\n", buf);
else
printk("%s...\n",buf);
printk("%s...\n", buf);
#endif /* DUMP_PACKETS > 0 */
if (memcmp(skb->data, lec_ctrl_magic, 4) ==0) { /* Control frame, to daemon*/
if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) { /* Control frame, to daemon */
struct sock *sk = sk_atm(vcc);
DPRINTK("%s: To daemon\n",dev->name);
DPRINTK("%s: To daemon\n", dev->name);
skb_queue_tail(&sk->sk_receive_queue, skb);
sk->sk_data_ready(sk, skb->len);
} else { /* Data frame, queue to protocol handlers */
struct lec_arp_table *entry;
unsigned char *src, *dst;
atm_return(vcc,skb->truesize);
if (*(uint16_t *)skb->data == htons(priv->lecid) ||
!priv->lecd ||
!(dev->flags & IFF_UP)) {
/* Probably looping back, or if lecd is missing,
lecd has gone down */
atm_return(vcc, skb->truesize);
if (*(uint16_t *) skb->data == htons(priv->lecid) ||
!priv->lecd || !(dev->flags & IFF_UP)) {
/*
* Probably looping back, or if lecd is missing,
* lecd has gone down
*/
DPRINTK("Ignoring frame...\n");
dev_kfree_skb(skb);
return;
}
#ifdef CONFIG_TR
if (priv->is_trdev)
dst = ((struct lecdatahdr_8025 *) skb->data)->h_dest;
dst = ((struct lecdatahdr_8025 *)skb->data)->h_dest;
else
#endif
dst = ((struct lecdatahdr_8023 *) skb->data)->h_dest;
dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest;
/* If this is a Data Direct VCC, and the VCC does not match
/*
* If this is a Data Direct VCC, and the VCC does not match
* the LE_ARP cache entry, delete the LE_ARP cache entry.
*/
spin_lock_irqsave(&priv->lec_arp_lock, flags);
if (lec_is_data_direct(vcc)) {
#ifdef CONFIG_TR
if (priv->is_trdev)
src = ((struct lecdatahdr_8025 *) skb->data)->h_source;
src =
((struct lecdatahdr_8025 *)skb->data)->
h_source;
else
#endif
src = ((struct lecdatahdr_8023 *) skb->data)->h_source;
src =
((struct lecdatahdr_8023 *)skb->data)->
h_source;
entry = lec_arp_find(priv, src);
if (entry && entry->vcc != vcc) {
lec_arp_remove(priv, entry);
......@@ -777,7 +800,7 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
}
spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
if (!(dst[0]&0x01) && /* Never filter Multi/Broadcast */
if (!(dst[0] & 0x01) && /* Never filter Multi/Broadcast */
!priv->is_proxy && /* Proxy wants all the packets */
memcmp(dst, dev->dev_addr, dev->addr_len)) {
dev_kfree_skb(skb);
......@@ -789,7 +812,8 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
skb->dev = dev;
skb_pull(skb, 2); /* skip lec_id */
#ifdef CONFIG_TR
if (priv->is_trdev) skb->protocol = tr_type_trans(skb, dev);
if (priv->is_trdev)
skb->protocol = tr_type_trans(skb, dev);
else
#endif
skb->protocol = eth_type_trans(skb, dev);
......@@ -800,8 +824,7 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
}
}
static void
lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
{
struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc);
struct net_device *dev = skb->dev;
......@@ -820,8 +843,7 @@ lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
}
}
static int
lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
{
struct lec_vcc_priv *vpriv;
int bytes_left;
......@@ -830,7 +852,8 @@ lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
/* Lecd must be up in this case */
bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc));
if (bytes_left != 0) {
printk("lec: lec_vcc_attach, copy from user failed for %d bytes\n",
printk
("lec: lec_vcc_attach, copy from user failed for %d bytes\n",
bytes_left);
}
if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF ||
......@@ -849,23 +872,21 @@ lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
return 0;
}
static int
lec_mcast_attach(struct atm_vcc *vcc, int arg)
static int lec_mcast_attach(struct atm_vcc *vcc, int arg)
{
if (arg <0 || arg >= MAX_LEC_ITF || !dev_lec[arg])
if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg])
return -EINVAL;
vcc->proto_data = dev_lec[arg];
return (lec_mcast_make((struct lec_priv*)dev_lec[arg]->priv, vcc));
return (lec_mcast_make((struct lec_priv *)dev_lec[arg]->priv, vcc));
}
/* Initialize device. */
static int
lecd_attach(struct atm_vcc *vcc, int arg)
static int lecd_attach(struct atm_vcc *vcc, int arg)
{
int i;
struct lec_priv *priv;
if (arg<0)
if (arg < 0)
i = 0;
else
i = arg;
......@@ -873,7 +894,7 @@ lecd_attach(struct atm_vcc *vcc, int arg)
if (arg >= MAX_LEC_ITF)
return -EINVAL;
#else /* Reserve the top NUM_TR_DEVS for TR */
if (arg >= (MAX_LEC_ITF-NUM_TR_DEVS))
if (arg >= (MAX_LEC_ITF - NUM_TR_DEVS))
return -EINVAL;
#endif
if (!dev_lec[i]) {
......@@ -913,20 +934,20 @@ lecd_attach(struct atm_vcc *vcc, int arg)
vcc_insert_socket(sk_atm(vcc));
vcc->proto_data = dev_lec[i];
set_bit(ATM_VF_META,&vcc->flags);
set_bit(ATM_VF_READY,&vcc->flags);
set_bit(ATM_VF_META, &vcc->flags);
set_bit(ATM_VF_READY, &vcc->flags);
/* Set default values to these variables */
priv->maximum_unknown_frame_count = 1;
priv->max_unknown_frame_time = (1*HZ);
priv->vcc_timeout_period = (1200*HZ);
priv->max_unknown_frame_time = (1 * HZ);
priv->vcc_timeout_period = (1200 * HZ);
priv->max_retry_count = 1;
priv->aging_time = (300*HZ);
priv->forward_delay_time = (15*HZ);
priv->aging_time = (300 * HZ);
priv->forward_delay_time = (15 * HZ);
priv->topology_change = 0;
priv->arp_response_time = (1*HZ);
priv->flush_timeout = (4*HZ);
priv->path_switching_delay = (6*HZ);
priv->arp_response_time = (1 * HZ);
priv->flush_timeout = (4 * HZ);
priv->path_switching_delay = (6 * HZ);
if (dev_lec[i]->flags & IFF_UP) {
netif_start_queue(dev_lec[i]);
......@@ -936,7 +957,7 @@ lecd_attach(struct atm_vcc *vcc, int arg)
}
#ifdef CONFIG_PROC_FS
static char* lec_arp_get_status_string(unsigned char status)
static char *lec_arp_get_status_string(unsigned char status)
{
static char *lec_arp_status_string[] = {
"ESI_UNKNOWN ",
......@@ -974,7 +995,6 @@ static void lec_info(struct seq_file *seq, struct lec_arp_table *entry)
seq_putc(seq, '\n');
}
struct lec_state {
unsigned long flags;
struct lec_priv *locked;
......@@ -1046,8 +1066,7 @@ static void *lec_priv_walk(struct lec_state *state, loff_t *l,
state->locked = priv;
spin_lock_irqsave(&priv->lec_arp_lock, state->flags);
}
if (!lec_arp_walk(state, l, priv) &&
!lec_misc_walk(state, l, priv)) {
if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) {
spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags);
state->locked = NULL;
/* Partial state reset for the next time we get called */
......@@ -1095,7 +1114,7 @@ static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
state->misc_table = 0;
state->entry = (void *)1;
return *pos ? lec_get_idx(state, *pos) : (void*)1;
return *pos ? lec_get_idx(state, *pos) : (void *)1;
}
static void lec_seq_stop(struct seq_file *seq, void *v)
......@@ -1200,15 +1219,15 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
switch (cmd) {
case ATMLEC_CTRL:
err = lecd_attach(vcc, (int) arg);
err = lecd_attach(vcc, (int)arg);
if (err >= 0)
sock->state = SS_CONNECTED;
break;
case ATMLEC_MCAST:
err = lec_mcast_attach(vcc, (int) arg);
err = lec_mcast_attach(vcc, (int)arg);
break;
case ATMLEC_DATA:
err = lec_vcc_attach(vcc, (void __user *) arg);
err = lec_vcc_attach(vcc, (void __user *)arg);
break;
}
......@@ -1279,7 +1298,7 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
spin_lock_irqsave(&priv->lec_arp_lock, flags);
table = lec_arp_find(priv, dst_mac);
spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
if(table == NULL)
if (table == NULL)
return -1;
*tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC);
......@@ -1306,7 +1325,6 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
return retval;
}
/*
* LANE2: 3.1.4, LE_ASSOCIATE.request
* Associate the *tlvs with the *lan_dst address.
......@@ -1314,12 +1332,12 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
* Returns 1 for success, 0 for failure (out of memory)
*
*/
static int lane2_associate_req (struct net_device *dev, u8 *lan_dst,
static int lane2_associate_req(struct net_device *dev, u8 *lan_dst,
u8 *tlvs, u32 sizeoftlvs)
{
int retval;
struct sk_buff *skb;
struct lec_priv *priv = (struct lec_priv*)dev->priv;
struct lec_priv *priv = (struct lec_priv *)dev->priv;
if (compare_ether_addr(lan_dst, dev->dev_addr))
return (0); /* not our mac address */
......@@ -1340,7 +1358,8 @@ static int lane2_associate_req (struct net_device *dev, u8 *lan_dst,
retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb);
if (retval != 0)
printk("lec.c: lane2_associate_req() failed\n");
/* If the previous association has changed we must
/*
* If the previous association has changed we must
* somehow notify other LANE entities about the change
*/
return (1);
......@@ -1350,15 +1369,19 @@ static int lane2_associate_req (struct net_device *dev, u8 *lan_dst,
* LANE2: 3.1.5, LE_ASSOCIATE.indication
*
*/
static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr,
static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr,
u8 *tlvs, u32 sizeoftlvs)
{
#if 0
int i = 0;
#endif
struct lec_priv *priv = (struct lec_priv *)dev->priv;
#if 0 /* Why have the TLVs in LE_ARP entries since we do not use them? When you
uncomment this code, make sure the TLVs get freed when entry is killed */
#if 0 /*
* Why have the TLVs in LE_ARP entries
* since we do not use them? When you
* uncomment this code, make sure the
* TLVs get freed when entry is killed
*/
struct lec_arp_table *entry = lec_arp_find(priv, mac_addr);
if (entry == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment