Commit aa7815ef authored by Alexander Viro's avatar Alexander Viro Committed by Stephen Hemminger

[wan hdlc] hdlc_fr: eliminated ->netdev, hdlc_to_dev() and hdlc_to_name() uses.

parent 8f3c812a
......@@ -146,8 +146,9 @@ static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci)
}
static inline pvc_device* add_pvc(hdlc_device *hdlc, u16 dlci)
static inline pvc_device* add_pvc(struct net_device *dev, u16 dlci)
{
hdlc_device *hdlc = dev_to_hdlc(dev);
pvc_device *pvc, **pvc_p = &hdlc->state.fr.first_pvc;
while (*pvc_p) {
......@@ -164,7 +165,7 @@ static inline pvc_device* add_pvc(hdlc_device *hdlc, u16 dlci)
memset(pvc, 0, sizeof(pvc_device));
pvc->dlci = dlci;
pvc->master = hdlc;
pvc->master = dev;
pvc->next = *pvc_p; /* Put it in the chain */
*pvc_p = pvc;
return pvc;
......@@ -311,15 +312,16 @@ static int pvc_open(struct net_device *dev)
{
pvc_device *pvc = dev_to_pvc(dev);
if ((hdlc_to_dev(pvc->master)->flags & IFF_UP) == 0)
if ((pvc->master->flags & IFF_UP) == 0)
return -EIO; /* Master must be UP in order to activate PVC */
if (pvc->open_count++ == 0) {
if (pvc->master->state.fr.settings.lmi == LMI_NONE)
pvc->state.active = pvc->master->carrier;
hdlc_device *hdlc = dev_to_hdlc(pvc->master);
if (hdlc->state.fr.settings.lmi == LMI_NONE)
pvc->state.active = hdlc->carrier;
pvc_carrier(pvc->state.active, pvc);
pvc->master->state.fr.dce_changed = 1;
hdlc->state.fr.dce_changed = 1;
}
return 0;
}
......@@ -331,11 +333,12 @@ static int pvc_close(struct net_device *dev)
pvc_device *pvc = dev_to_pvc(dev);
if (--pvc->open_count == 0) {
if (pvc->master->state.fr.settings.lmi == LMI_NONE)
hdlc_device *hdlc = dev_to_hdlc(pvc->master);
if (hdlc->state.fr.settings.lmi == LMI_NONE)
pvc->state.active = 0;
if (pvc->master->state.fr.settings.dce) {
pvc->master->state.fr.dce_changed = 1;
if (hdlc->state.fr.settings.dce) {
hdlc->state.fr.dce_changed = 1;
pvc->state.active = 0;
}
}
......@@ -362,7 +365,7 @@ int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
}
info.dlci = pvc->dlci;
memcpy(info.master, hdlc_to_name(pvc->master), IFNAMSIZ);
memcpy(info.master, pvc->master->name, IFNAMSIZ);
if (copy_to_user(ifr->ifr_settings.ifs_ifsu.fr_pvc_info,
&info, sizeof(info)))
return -EFAULT;
......@@ -408,7 +411,7 @@ static int pvc_xmit(struct sk_buff *skb, struct net_device *dev)
stats->tx_packets++;
if (pvc->state.fecn) /* TX Congestion counter */
stats->tx_compressed++;
skb->dev = hdlc_to_dev(pvc->master);
skb->dev = pvc->master;
dev_queue_xmit(skb);
return 0;
}
......@@ -434,7 +437,7 @@ static int pvc_change_mtu(struct net_device *dev, int new_mtu)
static inline void fr_log_dlci_active(pvc_device *pvc)
{
printk(KERN_INFO "%s: DLCI %d [%s%s%s]%s %s\n",
hdlc_to_name(pvc->master),
pvc->master->name,
pvc->dlci,
pvc->main ? pvc->main->name : "",
pvc->main && pvc->ether ? " " : "",
......@@ -454,8 +457,9 @@ static inline u8 fr_lmi_nextseq(u8 x)
static void fr_lmi_send(hdlc_device *hdlc, int fullrep)
static void fr_lmi_send(struct net_device *dev, int fullrep)
{
hdlc_device *hdlc = dev_to_hdlc(dev);
struct sk_buff *skb;
pvc_device *pvc = hdlc->state.fr.first_pvc;
int len = (hdlc->state.fr.settings.lmi == LMI_ANSI) ? LMI_ANSI_LENGTH
......@@ -468,7 +472,7 @@ static void fr_lmi_send(hdlc_device *hdlc, int fullrep)
len += hdlc->state.fr.dce_pvc_count * (2 + stat_len);
if (len > HDLC_MAX_MRU) {
printk(KERN_WARNING "%s: Too many PVCs while sending "
"LMI full report\n", hdlc_to_name(hdlc));
"LMI full report\n", dev->name);
return;
}
}
......@@ -476,7 +480,7 @@ static void fr_lmi_send(hdlc_device *hdlc, int fullrep)
skb = dev_alloc_skb(len);
if (!skb) {
printk(KERN_WARNING "%s: Memory squeeze on fr_lmi_send()\n",
hdlc_to_name(hdlc));
dev->name);
return;
}
memset(skb->data, 0, len);
......@@ -529,7 +533,7 @@ static void fr_lmi_send(hdlc_device *hdlc, int fullrep)
skb_put(skb, i);
skb->priority = TC_PRIO_CONTROL;
skb->dev = hdlc_to_dev(hdlc);
skb->dev = dev;
skb->nh.raw = skb->data;
dev_queue_xmit(skb);
......@@ -537,14 +541,15 @@ static void fr_lmi_send(hdlc_device *hdlc, int fullrep)
static void fr_set_link_state(int reliable, hdlc_device *hdlc)
static void fr_set_link_state(int reliable, struct net_device *dev)
{
hdlc_device *hdlc = dev_to_hdlc(dev);
pvc_device *pvc = hdlc->state.fr.first_pvc;
hdlc->state.fr.reliable = reliable;
if (reliable) {
if (!netif_carrier_ok(&hdlc->netdev))
netif_carrier_on(&hdlc->netdev);
if (!netif_carrier_ok(dev))
netif_carrier_on(dev);
hdlc->state.fr.n391cnt = 0; /* Request full status */
hdlc->state.fr.dce_changed = 1;
......@@ -558,8 +563,8 @@ static void fr_set_link_state(int reliable, hdlc_device *hdlc)
}
}
} else {
if (netif_carrier_ok(&hdlc->netdev))
netif_carrier_off(&hdlc->netdev);
if (netif_carrier_ok(dev))
netif_carrier_off(dev);
while (pvc) { /* Deactivate all PVCs */
pvc_carrier(0, pvc);
......@@ -574,7 +579,8 @@ static void fr_set_link_state(int reliable, hdlc_device *hdlc)
static void fr_timer(unsigned long arg)
{
hdlc_device *hdlc = (hdlc_device*)arg;
struct net_device *dev = (struct net_device *)arg;
hdlc_device *hdlc = dev_to_hdlc(dev);
int i, cnt = 0, reliable;
u32 list;
......@@ -586,7 +592,7 @@ static void fr_timer(unsigned long arg)
if (hdlc->state.fr.request) {
if (hdlc->state.fr.reliable)
printk(KERN_INFO "%s: No LMI status reply "
"received\n", hdlc_to_name(hdlc));
"received\n", dev->name);
hdlc->state.fr.last_errors |= 1;
}
......@@ -598,9 +604,9 @@ static void fr_timer(unsigned long arg)
}
if (hdlc->state.fr.reliable != reliable) {
printk(KERN_INFO "%s: Link %sreliable\n", hdlc_to_name(hdlc),
printk(KERN_INFO "%s: Link %sreliable\n", dev->name,
reliable ? "" : "un");
fr_set_link_state(reliable, hdlc);
fr_set_link_state(reliable, dev);
}
if (hdlc->state.fr.settings.dce)
......@@ -610,7 +616,7 @@ static void fr_timer(unsigned long arg)
if (hdlc->state.fr.n391cnt)
hdlc->state.fr.n391cnt--;
fr_lmi_send(hdlc, hdlc->state.fr.n391cnt == 0);
fr_lmi_send(dev, hdlc->state.fr.n391cnt == 0);
hdlc->state.fr.request = 1;
hdlc->state.fr.timer.expires = jiffies +
......@@ -624,8 +630,9 @@ static void fr_timer(unsigned long arg)
static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb)
static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb)
{
hdlc_device *hdlc = dev_to_hdlc(dev);
int stat_len;
pvc_device *pvc;
int reptype = -1, error, no_ram;
......@@ -634,14 +641,14 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb)
if (skb->len < ((hdlc->state.fr.settings.lmi == LMI_ANSI)
? LMI_ANSI_LENGTH : LMI_LENGTH)) {
printk(KERN_INFO "%s: Short LMI frame\n", hdlc_to_name(hdlc));
printk(KERN_INFO "%s: Short LMI frame\n", dev->name);
return 1;
}
if (skb->data[5] != (!hdlc->state.fr.settings.dce ?
LMI_STATUS : LMI_STATUS_ENQUIRY)) {
printk(KERN_INFO "%s: LMI msgtype=%x, Not LMI status %s\n",
hdlc_to_name(hdlc), skb->data[2],
dev->name, skb->data[2],
hdlc->state.fr.settings.dce ? "enquiry" : "reply");
return 1;
}
......@@ -652,7 +659,7 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb)
((hdlc->state.fr.settings.lmi == LMI_CCITT)
? LMI_CCITT_REPTYPE : LMI_REPTYPE)) {
printk(KERN_INFO "%s: Not a report type=%x\n",
hdlc_to_name(hdlc), skb->data[i]);
dev->name, skb->data[i]);
return 1;
}
i++;
......@@ -665,7 +672,7 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb)
((hdlc->state.fr.settings.lmi == LMI_CCITT)
? LMI_CCITT_ALIVE : LMI_ALIVE)) {
printk(KERN_INFO "%s: Unsupported status element=%x\n",
hdlc_to_name(hdlc), skb->data[i]);
dev->name, skb->data[i]);
return 1;
}
i++;
......@@ -680,7 +687,7 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb)
if (hdlc->state.fr.settings.dce) {
if (reptype != LMI_FULLREP && reptype != LMI_INTEGRITY) {
printk(KERN_INFO "%s: Unsupported report type=%x\n",
hdlc_to_name(hdlc), reptype);
dev->name, reptype);
return 1;
}
}
......@@ -716,7 +723,7 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb)
hdlc->state.fr.dce_changed = 0;
}
fr_lmi_send(hdlc, reptype == LMI_FULLREP ? 1 : 0);
fr_lmi_send(dev, reptype == LMI_FULLREP ? 1 : 0);
return 0;
}
......@@ -741,26 +748,26 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb)
if (skb->data[i] != ((hdlc->state.fr.settings.lmi == LMI_CCITT)
? LMI_CCITT_PVCSTAT : LMI_PVCSTAT)) {
printk(KERN_WARNING "%s: Invalid PVCSTAT ID: %x\n",
hdlc_to_name(hdlc), skb->data[i]);
dev->name, skb->data[i]);
return 1;
}
i++;
if (skb->data[i] != stat_len) {
printk(KERN_WARNING "%s: Invalid PVCSTAT length: %x\n",
hdlc_to_name(hdlc), skb->data[i]);
dev->name, skb->data[i]);
return 1;
}
i++;
dlci = status_to_dlci(skb->data + i, &active, &new);
pvc = add_pvc(hdlc, dlci);
pvc = add_pvc(dev, dlci);
if (!pvc && !no_ram) {
printk(KERN_WARNING
"%s: Memory squeeze on fr_lmi_recv()\n",
hdlc_to_name(hdlc));
dev->name);
no_ram = 1;
}
......@@ -802,7 +809,8 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb)
static int fr_rx(struct sk_buff *skb)
{
hdlc_device *hdlc = dev_to_hdlc(skb->dev);
struct net_device *ndev = skb->dev;
hdlc_device *hdlc = dev_to_hdlc(ndev);
fr_hdr *fh = (fr_hdr*)skb->data;
u8 *data = skb->data;
u16 dlci;
......@@ -819,7 +827,7 @@ static int fr_rx(struct sk_buff *skb)
goto rx_error; /* LMI packet with no LMI? */
if (data[3] == LMI_PROTO) {
if (fr_lmi_recv(hdlc, skb))
if (fr_lmi_recv(ndev, skb))
goto rx_error;
else {
/* No request pending */
......@@ -831,7 +839,7 @@ static int fr_rx(struct sk_buff *skb)
}
printk(KERN_INFO "%s: Received non-LMI frame with LMI DLCI\n",
hdlc_to_name(hdlc));
ndev->name);
goto rx_error;
}
......@@ -839,7 +847,7 @@ static int fr_rx(struct sk_buff *skb)
if (!pvc) {
#ifdef DEBUG_PKT
printk(KERN_INFO "%s: No PVC for received frame's DLCI %d\n",
hdlc_to_name(hdlc), dlci);
ndev->name, dlci);
#endif
dev_kfree_skb_any(skb);
return NET_RX_DROP;
......@@ -847,7 +855,7 @@ static int fr_rx(struct sk_buff *skb)
if (pvc->state.fecn != fh->fecn) {
#ifdef DEBUG_ECN
printk(KERN_DEBUG "%s: DLCI %d FECN O%s\n", hdlc_to_name(pvc),
printk(KERN_DEBUG "%s: DLCI %d FECN O%s\n", ndev->name,
dlci, fh->fecn ? "N" : "FF");
#endif
pvc->state.fecn ^= 1;
......@@ -855,7 +863,7 @@ static int fr_rx(struct sk_buff *skb)
if (pvc->state.becn != fh->becn) {
#ifdef DEBUG_ECN
printk(KERN_DEBUG "%s: DLCI %d BECN O%s\n", hdlc_to_name(pvc),
printk(KERN_DEBUG "%s: DLCI %d BECN O%s\n", ndev->name,
dlci, fh->becn ? "N" : "FF");
#endif
pvc->state.becn ^= 1;
......@@ -899,13 +907,13 @@ static int fr_rx(struct sk_buff *skb)
default:
printk(KERN_INFO "%s: Unsupported protocol, OUI=%x "
"PID=%x\n", hdlc_to_name(hdlc), oui, pid);
"PID=%x\n", ndev->name, oui, pid);
dev_kfree_skb_any(skb);
return NET_RX_DROP;
}
} else {
printk(KERN_INFO "%s: Unsupported protocol, NLPID=%x "
"length = %i\n", hdlc_to_name(hdlc), data[3], skb->len);
"length = %i\n", ndev->name, data[3], skb->len);
dev_kfree_skb_any(skb);
return NET_RX_DROP;
}
......@@ -954,10 +962,10 @@ static void fr_start(struct net_device *dev)
/* First poll after 1 s */
hdlc->state.fr.timer.expires = jiffies + HZ;
hdlc->state.fr.timer.function = fr_timer;
hdlc->state.fr.timer.data = (unsigned long)hdlc;
hdlc->state.fr.timer.data = (unsigned long)dev;
add_timer(&hdlc->state.fr.timer);
} else
fr_set_link_state(1, hdlc);
fr_set_link_state(1, dev);
}
......@@ -970,7 +978,7 @@ static void fr_stop(struct net_device *dev)
#endif
if (hdlc->state.fr.settings.lmi != LMI_NONE)
del_timer_sync(&hdlc->state.fr.timer);
fr_set_link_state(0, hdlc);
fr_set_link_state(0, dev);
}
......@@ -991,8 +999,9 @@ static void fr_close(struct net_device *dev)
static int fr_add_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
static int fr_add_pvc(struct net_device *master, unsigned int dlci, int type)
{
hdlc_device *hdlc = dev_to_hdlc(master);
pvc_device *pvc = NULL;
struct net_device *dev;
int result, used;
......@@ -1001,9 +1010,9 @@ static int fr_add_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
if (type == ARPHRD_ETHER)
prefix = "pvceth%d";
if ((pvc = add_pvc(hdlc, dlci)) == NULL) {
if ((pvc = add_pvc(master, dlci)) == NULL) {
printk(KERN_WARNING "%s: Memory squeeze on fr_add_pvc()\n",
hdlc_to_name(hdlc));
master->name);
return -ENOBUFS;
}
......@@ -1016,7 +1025,7 @@ static int fr_add_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
sizeof(struct net_device_stats), GFP_KERNEL);
if (!dev) {
printk(KERN_WARNING "%s: Memory squeeze on fr_pvc()\n",
hdlc_to_name(hdlc));
master->name);
delete_unused_pvcs(hdlc);
return -ENOBUFS;
}
......@@ -1120,12 +1129,12 @@ static void fr_destroy(hdlc_device *hdlc)
int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr)
{
fr_proto *fr_s = ifr->ifr_settings.ifs_ifsu.fr;
const size_t size = sizeof(fr_proto);
fr_proto new_settings;
struct net_device *dev = hdlc_to_dev(hdlc);
hdlc_device *hdlc = dev_to_hdlc(dev);
fr_proto_pvc pvc;
int result;
......@@ -1213,7 +1222,7 @@ int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
if (ifr->ifr_settings.type == IF_PROTO_FR_ADD_PVC ||
ifr->ifr_settings.type == IF_PROTO_FR_ADD_ETH_PVC)
return fr_add_pvc(hdlc, pvc.dlci, result);
return fr_add_pvc(dev, pvc.dlci, result);
else
return fr_del_pvc(hdlc, pvc.dlci, result);
}
......
......@@ -185,7 +185,7 @@ void hdlc_close(struct net_device *dev)
#endif
#ifndef CONFIG_HDLC_FR
#define hdlc_fr_ioctl(hdlc, ifr) -ENOSYS
#define hdlc_fr_ioctl(dev, ifr) -ENOSYS
#endif
#ifndef CONFIG_HDLC_X25
......@@ -220,7 +220,7 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
case IF_PROTO_HDLC_ETH: return hdlc_raw_eth_ioctl(hdlc, ifr);
case IF_PROTO_PPP: return hdlc_ppp_ioctl(hdlc, ifr);
case IF_PROTO_CISCO: return hdlc_cisco_ioctl(dev, ifr);
case IF_PROTO_FR: return hdlc_fr_ioctl(hdlc, ifr);
case IF_PROTO_FR: return hdlc_fr_ioctl(dev, ifr);
case IF_PROTO_X25: return hdlc_x25_ioctl(hdlc, ifr);
default: return -EINVAL;
}
......
......@@ -75,7 +75,7 @@ typedef struct {
typedef struct pvc_device_struct {
struct hdlc_device_struct *master;
struct net_device *master;
struct net_device *main;
struct net_device *ether; /* bridged Ethernet interface */
struct pvc_device_struct *next; /* Sorted in ascending DLCI order */
......@@ -175,7 +175,7 @@ int hdlc_raw_ioctl(hdlc_device *hdlc, struct ifreq *ifr);
int hdlc_raw_eth_ioctl(hdlc_device *hdlc, struct ifreq *ifr);
int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr);
int hdlc_ppp_ioctl(hdlc_device *hdlc, struct ifreq *ifr);
int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr);
int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr);
int hdlc_x25_ioctl(hdlc_device *hdlc, struct ifreq *ifr);
......
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