From: Karl Hiramoto <karl@hiramoto.org>
To: netdev@vger.kernel.org, linux-atm-general@lists.sourceforge.net
Cc: chas@cmf.nrl.navy.mil, davem@davemloft.net,
Karl Hiramoto <karl@hiramoto.org>
Subject: [PATCH] atmtcp: add sysfs attr for changing atm carrier signal state.
Date: Sun, 3 Oct 2010 21:51:25 +0200 [thread overview]
Message-ID: <1286135485-27355-1-git-send-email-karl@hiramoto.org> (raw)
This will be used for device testing carrier signal changes in other parts of
the atm stack.
Carrier lost set by:
echo -n 0 > /sys/class/atm/atmtcp0/carrier
Carrier detected:
echo -n 1 > /sys/class/atm/atmtcp0/carrier
Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
---
drivers/atm/atmtcp.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
index b910181..7540e33 100644
--- a/drivers/atm/atmtcp.c
+++ b/drivers/atm/atmtcp.c
@@ -210,6 +210,18 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
atomic_inc(&vcc->stats->tx_err);
return -ENOLINK;
}
+
+ if (vcc->dev->signal == ATM_PHY_SIG_LOST) {
+ pr_warning(DEV_LABEL ": Dropping TX pkt, upper layer not handling carrier signal lost\n");
+ if (vcc->pop)
+ vcc->pop(vcc, skb);
+ else
+ dev_kfree_skb(skb);
+
+ atomic_inc(&vcc->stats->tx_err);
+ return -ENOLINK;
+ }
+
size = skb->len+sizeof(struct atmtcp_hdr);
new_skb = atm_alloc_charge(out_vcc,size,GFP_ATOMIC);
if (!new_skb) {
@@ -304,6 +316,12 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
atomic_inc(&vcc->stats->tx_err);
goto done;
}
+
+ if (out_vcc->dev->signal == ATM_PHY_SIG_LOST) {
+ pr_debug(DEV_LABEL ": Dropping RX pkt while no carrier signal\n");
+ result = -ENOLINK;
+ goto done;
+ }
skb_pull(skb,sizeof(struct atmtcp_hdr));
new_skb = atm_alloc_charge(out_vcc,skb->len,GFP_KERNEL);
if (!new_skb) {
@@ -356,6 +374,43 @@ static struct atm_dev atmtcp_control_dev = {
.lock = __SPIN_LOCK_UNLOCKED(atmtcp_control_dev.lock)
};
+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 *atmtcp_attrs[] = {
+ &dev_attr_signal.attr,
+ NULL
+};
+
+static struct attribute_group atmtcp_group_attrs = {
+ .name = NULL, /* We want them in dev's root folder */
+ .attrs = atmtcp_attrs
+};
+
static int atmtcp_create(int itf,int persist,struct atm_dev **result)
{
@@ -376,6 +431,10 @@ static int atmtcp_create(int itf,int persist,struct atm_dev **result)
dev->dev_data = dev_data;
PRIV(dev)->vcc = NULL;
PRIV(dev)->persist = persist;
+
+ if (sysfs_create_group(&dev->class_dev.kobj, &atmtcp_group_attrs))
+ dev_err(&dev->class_dev, "Could not register sysfs attrs for atmtcp\n");
+
if (result) *result = dev;
return 0;
}
--
1.7.2.2
next reply other threads:[~2010-10-03 19:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-03 19:51 Karl Hiramoto [this message]
2010-10-03 20:00 ` [PATCH] atmtcp: add sysfs attr for changing atm carrier signal state David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1286135485-27355-1-git-send-email-karl@hiramoto.org \
--to=karl@hiramoto.org \
--cc=chas@cmf.nrl.navy.mil \
--cc=davem@davemloft.net \
--cc=linux-atm-general@lists.sourceforge.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).