* [PATCH 1/6] atm: add hooks to propagate signal changes to netdevice
2010-07-02 17:47 [PATCH 0/6] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice Karl Hiramoto
@ 2010-07-02 17:47 ` Karl Hiramoto
2010-07-02 17:47 ` [PATCH 2/6] atm br2684: add callback for carrier signal changes Karl Hiramoto
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Karl Hiramoto @ 2010-07-02 17:47 UTC (permalink / raw)
To: linux-atm-general, netdev, chas; +Cc: nathan, Karl Hiramoto
On DSL and ATM devices it's usefull to have a know if you have a carrier signal.
netdevice LOWER_UP changes can be propagated to userspace via netlink monitor.
Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
---
include/linux/atmdev.h | 5 +++++
net/atm/common.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
index 817b237..c6958ec 100644
--- a/include/linux/atmdev.h
+++ b/include/linux/atmdev.h
@@ -311,6 +311,7 @@ struct atm_vcc {
void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */
int (*push_oam)(struct atm_vcc *vcc,void *cell);
int (*send)(struct atm_vcc *vcc,struct sk_buff *skb);
+ void (*signal_change)(struct atm_vcc *vcc); /* optional. to propagate LOWER_UP */
void *dev_data; /* per-device data */
void *proto_data; /* per-protocol data */
struct k_atm_aal_stats *stats; /* pointer to AAL stats group */
@@ -431,6 +432,10 @@ struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
int number,unsigned long *flags); /* number == -1: pick first available */
struct atm_dev *atm_dev_lookup(int number);
void atm_dev_deregister(struct atm_dev *dev);
+/**
+* Propagate lower layer signal change in atm_dev->signal to netdevice.
+*/
+void atm_dev_signal_change(struct atm_dev *dev, char signal);
void vcc_insert_socket(struct sock *sk);
diff --git a/net/atm/common.c b/net/atm/common.c
index b43feb1..ccf09f2 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -212,6 +212,39 @@ void vcc_release_async(struct atm_vcc *vcc, int reply)
}
EXPORT_SYMBOL(vcc_release_async);
+void atm_dev_signal_change(struct atm_dev *dev, char signal)
+{
+ int i;
+ pr_debug("%s signal=%d dev=%p number=%d dev->signal=%d\n",
+ __func__, signal, dev, dev->number, dev->signal);
+
+ if (dev->signal == signal)
+ return; /* no change */
+
+ dev->signal = signal;
+
+ read_lock_irq(&vcc_sklist_lock);
+ for (i = 0; i < VCC_HTABLE_SIZE; i++) {
+ struct hlist_head *head = &vcc_hash[i];
+ struct hlist_node *node, *tmp;
+ struct sock *s;
+ struct atm_vcc *vcc;
+ sk_for_each_safe(s, node, tmp, head) {
+ vcc = atm_sk(s);
+ pr_debug("%s signal=%d vcc=%p dev=%p vcc->dev=%p %d.%d itf=%d meta=%d\n",
+ __func__, signal, vcc, dev, vcc->dev,
+ vcc->vpi, vcc->vci, vcc->itf, test_bit(ATM_VF_META, &vcc->flags));
+ /* if there is a signal change callback and dev matches,
+ or if this is a meta dev (clip atm_dev is arpd) */
+ if (vcc->signal_change && (vcc->dev == dev
+ || test_bit(ATM_VF_META, &vcc->flags))) {
+ vcc->signal_change(vcc);
+ }
+ }
+ }
+ read_unlock_irq(&vcc_sklist_lock);
+}
+EXPORT_SYMBOL(atm_dev_signal_change);
void atm_dev_release_vccs(struct atm_dev *dev)
{
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] atm br2684: add callback for carrier signal changes.
2010-07-02 17:47 [PATCH 0/6] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice Karl Hiramoto
2010-07-02 17:47 ` [PATCH 1/6] atm: add hooks to propagate signal changes to netdevice Karl Hiramoto
@ 2010-07-02 17:47 ` Karl Hiramoto
2010-07-02 17:47 ` [PATCH 3/6] atm/idt77105.c: call atm_dev_signal_change() when " Karl Hiramoto
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Karl Hiramoto @ 2010-07-02 17:47 UTC (permalink / raw)
To: linux-atm-general, netdev, chas; +Cc: nathan, Karl Hiramoto
When a signal change event occurs call netif_carrier_on/off.
Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
---
net/atm/br2684.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 6719af6..e0136ec 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -448,6 +448,17 @@ free_skb:
dev_kfree_skb(skb);
}
+static void br2684_signal_change(struct atm_vcc *atmvcc)
+{
+ struct br2684_vcc *brvcc = BR2684_VCC(atmvcc);
+ struct net_device *net_dev = brvcc->device;
+
+ if (atmvcc->dev->signal == ATM_PHY_SIG_LOST)
+ netif_carrier_off(net_dev);
+ else
+ netif_carrier_on(net_dev);
+}
+
/*
* Assign a vcc to a dev
* Note: we do not have explicit unassign, but look at _push()
@@ -514,6 +525,7 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
barrier();
atmvcc->push = br2684_push;
atmvcc->pop = br2684_pop;
+ atmvcc->signal_change = br2684_signal_change;
__skb_queue_head_init(&queue);
rq = &sk_atm(atmvcc)->sk_receive_queue;
@@ -530,6 +542,7 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
br2684_push(atmvcc, skb);
}
+ br2684_signal_change(atmvcc); /* initialize netdev carrier state */
__module_get(THIS_MODULE);
return 0;
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] atm/idt77105.c: call atm_dev_signal_change() when signal changes.
2010-07-02 17:47 [PATCH 0/6] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice Karl Hiramoto
2010-07-02 17:47 ` [PATCH 1/6] atm: add hooks to propagate signal changes to netdevice Karl Hiramoto
2010-07-02 17:47 ` [PATCH 2/6] atm br2684: add callback for carrier signal changes Karl Hiramoto
@ 2010-07-02 17:47 ` Karl Hiramoto
2010-07-02 17:47 ` [PATCH 4/6] atm/solos-pci: " Karl Hiramoto
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Karl Hiramoto @ 2010-07-02 17:47 UTC (permalink / raw)
To: linux-atm-general, netdev, chas; +Cc: nathan, Karl Hiramoto
Propagate changes to upper atm layer.
Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
---
drivers/atm/idt77105.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c
index dab5cf5..bca9cb8 100644
--- a/drivers/atm/idt77105.c
+++ b/drivers/atm/idt77105.c
@@ -126,7 +126,7 @@ static void idt77105_restart_timer_func(unsigned long dummy)
istat = GET(ISTAT); /* side effect: clears all interrupt status bits */
if (istat & IDT77105_ISTAT_GOODSIG) {
/* Found signal again */
- dev->signal = ATM_PHY_SIG_FOUND;
+ atm_dev_signal_change(dev, ATM_PHY_SIG_FOUND);
printk(KERN_NOTICE "%s(itf %d): signal detected again\n",
dev->type,dev->number);
/* flush the receive FIFO */
@@ -222,7 +222,7 @@ static void idt77105_int(struct atm_dev *dev)
/* Rx Signal Condition Change - line went up or down */
if (istat & IDT77105_ISTAT_GOODSIG) { /* signal detected again */
/* This should not happen (restart timer does it) but JIC */
- dev->signal = ATM_PHY_SIG_FOUND;
+ atm_dev_signal_change(dev, ATM_PHY_SIG_FOUND);
} else { /* signal lost */
/*
* Disable interrupts and stop all transmission and
@@ -235,7 +235,7 @@ static void idt77105_int(struct atm_dev *dev)
IDT77105_MCR_DRIC|
IDT77105_MCR_HALTTX
) & ~IDT77105_MCR_EIP, MCR);
- dev->signal = ATM_PHY_SIG_LOST;
+ atm_dev_signal_change(dev, ATM_PHY_SIG_LOST);
printk(KERN_NOTICE "%s(itf %d): signal lost\n",
dev->type,dev->number);
}
@@ -272,8 +272,9 @@ static int idt77105_start(struct atm_dev *dev)
memset(&PRIV(dev)->stats,0,sizeof(struct idt77105_stats));
/* initialise dev->signal from Good Signal Bit */
- dev->signal = GET(ISTAT) & IDT77105_ISTAT_GOODSIG ? ATM_PHY_SIG_FOUND :
- ATM_PHY_SIG_LOST;
+ atm_dev_signal_change(dev,
+ GET(ISTAT) & IDT77105_ISTAT_GOODSIG ?
+ ATM_PHY_SIG_FOUND : ATM_PHY_SIG_LOST);
if (dev->signal == ATM_PHY_SIG_LOST)
printk(KERN_WARNING "%s(itf %d): no signal\n",dev->type,
dev->number);
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] atm/solos-pci: call atm_dev_signal_change() when signal changes.
2010-07-02 17:47 [PATCH 0/6] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice Karl Hiramoto
` (2 preceding siblings ...)
2010-07-02 17:47 ` [PATCH 3/6] atm/idt77105.c: call atm_dev_signal_change() when " Karl Hiramoto
@ 2010-07-02 17:47 ` Karl Hiramoto
2010-07-02 17:47 ` [PATCH 5/6] atm/suni.c: " Karl Hiramoto
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Karl Hiramoto @ 2010-07-02 17:47 UTC (permalink / raw)
To: linux-atm-general, netdev, chas; +Cc: nathan, Karl Hiramoto
Propagate changes to upper atm layer, so userspace netmontor knows when DSL showtime reached.
Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
---
drivers/atm/solos-pci.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index ded76c4..6174965 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -383,7 +383,7 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb
/* Anything but 'Showtime' is down */
if (strcmp(state_str, "Showtime")) {
- card->atmdev[port]->signal = ATM_PHY_SIG_LOST;
+ atm_dev_signal_change(card->atmdev[port], ATM_PHY_SIG_LOST);
release_vccs(card->atmdev[port]);
dev_info(&card->dev->dev, "Port %d: %s\n", port, state_str);
return 0;
@@ -401,7 +401,7 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb
snr[0]?", SNR ":"", snr, attn[0]?", Attn ":"", attn);
card->atmdev[port]->link_rate = rate_down / 424;
- card->atmdev[port]->signal = ATM_PHY_SIG_FOUND;
+ atm_dev_signal_change(card->atmdev[port], ATM_PHY_SIG_FOUND);
return 0;
}
@@ -1246,7 +1246,7 @@ static int atm_init(struct solos_card *card)
card->atmdev[i]->ci_range.vci_bits = 16;
card->atmdev[i]->dev_data = card;
card->atmdev[i]->phy_data = (void *)(unsigned long)i;
- card->atmdev[i]->signal = ATM_PHY_SIG_UNKNOWN;
+ atm_dev_signal_change(card->atmdev[i], ATM_PHY_SIG_UNKNOWN);
skb = alloc_skb(sizeof(*header), GFP_ATOMIC);
if (!skb) {
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] atm/suni.c: call atm_dev_signal_change() when signal changes.
2010-07-02 17:47 [PATCH 0/6] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice Karl Hiramoto
` (3 preceding siblings ...)
2010-07-02 17:47 ` [PATCH 4/6] atm/solos-pci: " Karl Hiramoto
@ 2010-07-02 17:47 ` Karl Hiramoto
2010-07-02 17:47 ` [PATCH 6/6] atm/adummy: add syfs DEVICE_ATTR to change signal Karl Hiramoto
2010-07-03 20:09 ` [Linux-ATM-General] [PATCH 0/6] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice chas williams - CONTRACTOR
6 siblings, 0 replies; 8+ messages in thread
From: Karl Hiramoto @ 2010-07-02 17:47 UTC (permalink / raw)
To: linux-atm-general, netdev, chas; +Cc: nathan, Karl Hiramoto
Propagate changes to upper atm layer.
Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
---
drivers/atm/suni.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
index da4b91f..41c56ea 100644
--- a/drivers/atm/suni.c
+++ b/drivers/atm/suni.c
@@ -291,8 +291,9 @@ static int suni_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
static void poll_los(struct atm_dev *dev)
{
- dev->signal = GET(RSOP_SIS) & SUNI_RSOP_SIS_LOSV ? ATM_PHY_SIG_LOST :
- ATM_PHY_SIG_FOUND;
+ atm_dev_signal_change(dev,
+ GET(RSOP_SIS) & SUNI_RSOP_SIS_LOSV ?
+ ATM_PHY_SIG_LOST : ATM_PHY_SIG_FOUND);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] atm/adummy: add syfs DEVICE_ATTR to change signal
2010-07-02 17:47 [PATCH 0/6] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice Karl Hiramoto
` (4 preceding siblings ...)
2010-07-02 17:47 ` [PATCH 5/6] atm/suni.c: " Karl Hiramoto
@ 2010-07-02 17:47 ` Karl Hiramoto
2010-07-03 20:09 ` [Linux-ATM-General] [PATCH 0/6] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice chas williams - CONTRACTOR
6 siblings, 0 replies; 8+ messages in thread
From: Karl Hiramoto @ 2010-07-02 17:47 UTC (permalink / raw)
To: linux-atm-general, netdev, chas; +Cc: nathan, Karl Hiramoto
Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
---
drivers/atm/adummy.c | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 6d44f07..46b9476 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -40,6 +40,42 @@ struct adummy_dev {
static LIST_HEAD(adummy_devs);
+static ssize_t __set_signal(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ struct atm_dev *atm_dev = container_of(dev, struct atm_dev, class_dev);
+ int signal;
+
+ if (sscanf(buf, "%d", &signal) == 1) {
+
+ if (signal < ATM_PHY_SIG_LOST || signal > ATM_PHY_SIG_FOUND)
+ signal = ATM_PHY_SIG_UNKNOWN;
+
+ atm_dev_signal_change(atm_dev, signal);
+ return 1;
+ }
+ return -EINVAL;
+}
+
+static ssize_t __show_signal(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct atm_dev *atm_dev = container_of(dev, struct atm_dev, class_dev);
+ return sprintf(buf, "%d\n", atm_dev->signal);
+}
+static DEVICE_ATTR(signal, 0644, __show_signal, __set_signal);
+
+static struct attribute *adummy_attrs[] = {
+ &dev_attr_signal.attr,
+ NULL
+};
+
+static struct attribute_group adummy_group_attrs = {
+ .name = NULL, /* We want them in dev's root folder */
+ .attrs = adummy_attrs
+};
+
static int __init
adummy_start(struct atm_dev *dev)
{
@@ -128,6 +164,9 @@ static int __init adummy_init(void)
adummy_dev->atm_dev = atm_dev;
atm_dev->dev_data = adummy_dev;
+ if (sysfs_create_group(&atm_dev->class_dev.kobj, &adummy_group_attrs))
+ dev_err(&atm_dev->class_dev, "Could not register attrs for adummy\n");
+
if (adummy_start(atm_dev)) {
printk(KERN_ERR DEV_LABEL ": adummy_start() failed\n");
err = -ENODEV;
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Linux-ATM-General] [PATCH 0/6] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice
2010-07-02 17:47 [PATCH 0/6] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice Karl Hiramoto
` (5 preceding siblings ...)
2010-07-02 17:47 ` [PATCH 6/6] atm/adummy: add syfs DEVICE_ATTR to change signal Karl Hiramoto
@ 2010-07-03 20:09 ` chas williams - CONTRACTOR
6 siblings, 0 replies; 8+ messages in thread
From: chas williams - CONTRACTOR @ 2010-07-03 20:09 UTC (permalink / raw)
To: Karl Hiramoto; +Cc: linux-atm-general, netdev
thanks for writing this. this is something that has been missing for
some time in the atm stack. however, i was hoping it could take a
different approach. i would prefer this mechanism to be more generic
instead of being only suitable for signalling carrier changes. take a
look at the notifier/register_netdevice_notifier scheme.
clients (like br2684) who wish to get these notifications, would need
to call register_atmdevice_notifier(). and yes, instead of handling
setting the signal flag yourself, everyone (including the drivers in
usb/atm) should be using the atm_dev_signal_change().
i am not fond of the idea of adding to the vcc struct something that
is really per device, not per vcc.
On Fri, 2 Jul 2010 19:47:04 +0200
Karl Hiramoto <karl@hiramoto.org> wrote:
> In userspace it's helpfull to know if a network device has a carrier
> signal. Often it is monitored via netlink. This patchset allows a
> way for the struct atm_dev drivers to pass carrier on/off to the
> netdevice.
>
> For DSL, carrier is on when the line has reached showtime state.
>
> Currently this patchset only propagates the changes to br2684 vccs,
> as this is the only type of hardware I have to test.
>
> If you prefer git you can pull from:
> git://github.com/karlhiramoto/linux-2.6.git linux-atm
>
> Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
>
> Karl Hiramoto (6):
> atm: add hooks to propagate signal changes to netdevice
> atm br2684: add callback for carrier signal changes.
> atm/idt77105.c: call atm_dev_signal_change() when signal changes.
> atm/solos-pci: call atm_dev_signal_change() when signal changes.
> atm/suni.c: call atm_dev_signal_change() when signal changes.
> atm/adummy: add syfs DEVICE_ATTR to change signal
>
> drivers/atm/adummy.c | 39
> +++++++++++++++++++++++++++++++++++++++ drivers/atm/idt77105.c |
> 11 ++++++----- drivers/atm/solos-pci.c | 6 +++---
> drivers/atm/suni.c | 5 +++--
> include/linux/atmdev.h | 5 +++++
> net/atm/br2684.c | 13 +++++++++++++
> net/atm/common.c | 33 +++++++++++++++++++++++++++++++++
> 7 files changed, 102 insertions(+), 10 deletions(-)
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Linux-atm-general mailing list
> Linux-atm-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-atm-general
>
^ permalink raw reply [flat|nested] 8+ messages in thread