* Re: [RFC 1/7] netdev: add standardized irq naming function
From: Michał Mirosław @ 2011-06-21 17:30 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: davem, netdev
In-Reply-To: <20110621170658.395370414@vyatta.com>
2011/6/21 Stephen Hemminger <shemminger@vyatta.com>:
> To force driver developers to use a standard convention for naming
> network device IRQ's, provide a standardized method for creating
> the name.
Can this be modified to track netdev renames?
Best Regards,
Michał Mirosław
^ permalink raw reply
* RE: [RFC 2/2] ethtool: Add support for DMA Coalescing feature config to ethtool.
From: Ben Hutchings @ 2011-06-21 17:38 UTC (permalink / raw)
To: Wyborny, Carolyn; +Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <EDC0E76513226749BFBC9C3FB031318F016F501D8D@orsmsx508.amr.corp.intel.com>
On Tue, 2011-06-21 at 10:23 -0700, Wyborny, Carolyn wrote:
>
> >-----Original Message-----
> >From: David Miller [mailto:davem@davemloft.net]
> >Sent: Friday, June 17, 2011 11:54 AM
> >To: Wyborny, Carolyn
> >Cc: netdev@vger.kernel.org; bhutchings@solarflare.com
> >Subject: Re: [RFC 2/2] ethtool: Add support for DMA Coalescing feature
> >config to ethtool.
> >
> >From: "Wyborny, Carolyn" <carolyn.wyborny@intel.com>
> >Date: Fri, 17 Jun 2011 08:50:11 -0700
> >
> >> I will add a fuller description of the feature in my updated patch.
> >> I thought the feature was more well known. Quick description is that
> >> it's a power saving feature that causes the adapter to coalesce its
> >> DMA writes at low traffic times to save power on the platform by
> >> reducing wakeups. The parameter is intended as a simple u32 value,
> >> not just an on or off, but also to allow a variety of configuration
> >> by adapter vendors, with validation of the input on the driver side.
> >> Since I left out the implementation in my patch, this wasn't clear.
> >> I will also fix this in my next submission.
> >
> >The value cannot have adapter specific meaning, you must define it
> >precisely and in a generic manner, such that the user can specify the
> >same setting across different card types.
>
> Ok, good point. I will refine the definition of the parameter in the
> next submission, once the dust clears on the major revisions in
> progress.
You may wish to propose a new command structure that covers both IRQ and
DMA moderation. They seem to be related, since DMA cannot be delayed
longer than the corresponding IRQ. We are currently lacking a way to
specify different IRQ moderation for multiqueue devices where the queues
are not all used in the same way.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* [net-next PATCH v2 1/7] dcb: Add DCBX capabilities bitmask to the get_ieee response
From: John Fastabend @ 2011-06-21 17:34 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
Adding the capabilities bitmask to the get_ieee response allows
user space to determine the current DCBX mode. Either CEE or IEEE
this is useful with devices that support switching between modes
where knowing the current state is relevant.
Derived from work by Mark Rustad
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
net/dcb/dcbnl.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index ed1bb8c..3a6d97d 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1288,6 +1288,7 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
struct nlattr *ieee, *app;
struct dcb_app_type *itr;
const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
+ int dcbx;
int err;
if (!ops)
@@ -1338,6 +1339,12 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
}
}
}
+
+ if (netdev->dcbnl_ops->getdcbx)
+ dcbx = netdev->dcbnl_ops->getdcbx(netdev);
+ else
+ dcbx = -EOPNOTSUPP;
+
spin_unlock(&dcb_lock);
nla_nest_end(skb, app);
@@ -1366,6 +1373,11 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
}
nla_nest_end(skb, ieee);
+ if (dcbx >= 0) {
+ err = nla_put_u8(skb, DCB_ATTR_DCBX, dcbx);
+ if (err)
+ goto nla_put_failure;
+ }
nlmsg_end(skb, nlh);
return rtnl_unicast(skb, &init_net, pid);
^ permalink raw reply related
* [net-next PATCH v2 2/7] net: dcbnl, add multicast group for DCB
From: John Fastabend @ 2011-06-21 17:34 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
In-Reply-To: <20110621173431.2777.39482.stgit@jf-dev1-dcblab>
Now that dcbnl is being used in many cases by more
than a single agent it is beneficial to be notified
when some entity either driver or user space has
changed the DCB attributes.
Today applications either end up polling the interface
or relying on a user space database to maintain the DCB
state and post events. Polling is a poor solution for
obvious reasons. And relying on a user space database
has its own downside. Namely it has created strange
boot dependencies requiring the database be populated
before any applications dependent on DCB attributes
starts or the application goes into a polling loop.
Populating the database requires negotiating link
setting with the peer and can take anywhere from less
than a second up to a few seconds depending on the switch
implementation.
Perhaps more importantly if another application or an
embedded agent sets a DCB link attribute the database
has no way of knowing other than polling the kernel.
This prevents applications from responding quickly to
changes in link events which at least in the FCoE case
and probably any other protocols expecting a lossless
link may result in IO errors.
By adding a multicast group for DCB we have clean way
to disseminate kernel DCB link attributes up to user
space. Avoiding the need for user space to maintain
a coherant database and disperse events that potentially
do not reflect the current link state.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/linux/rtnetlink.h | 2
include/net/dcbnl.h | 2
net/dcb/dcbnl.c | 229 +++++++++++++++++++++++++++++----------------
3 files changed, 150 insertions(+), 83 deletions(-)
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index bbad657..c81226a 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -585,6 +585,8 @@ enum rtnetlink_groups {
#define RTNLGRP_PHONET_IFADDR RTNLGRP_PHONET_IFADDR
RTNLGRP_PHONET_ROUTE,
#define RTNLGRP_PHONET_ROUTE RTNLGRP_PHONET_ROUTE
+ RTNLGRP_DCB,
+#define RTNLGRP_DCB RTNLGRP_DCB
__RTNLGRP_MAX
};
#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index e5983c9..b3cf10d 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -31,6 +31,8 @@ struct dcb_app_type {
u8 dcb_setapp(struct net_device *, struct dcb_app *);
u8 dcb_getapp(struct net_device *, struct dcb_app *);
+int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);
+
/*
* Ops struct for the netlink callbacks. Used by DCB-enabled drivers through
* the netdevice struct.
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 3a6d97d..ffba326 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1166,64 +1166,6 @@ err:
return ret;
}
-/* Handle IEEE 802.1Qaz SET commands. If any requested operation can not
- * be completed the entire msg is aborted and error value is returned.
- * No attempt is made to reconcile the case where only part of the
- * cmd can be completed.
- */
-static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
- u32 pid, u32 seq, u16 flags)
-{
- const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
- struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1];
- int err = -EOPNOTSUPP;
-
- if (!ops)
- goto err;
-
- err = nla_parse_nested(ieee, DCB_ATTR_IEEE_MAX,
- tb[DCB_ATTR_IEEE], dcbnl_ieee_policy);
- if (err)
- goto err;
-
- if (ieee[DCB_ATTR_IEEE_ETS] && ops->ieee_setets) {
- struct ieee_ets *ets = nla_data(ieee[DCB_ATTR_IEEE_ETS]);
- err = ops->ieee_setets(netdev, ets);
- if (err)
- goto err;
- }
-
- if (ieee[DCB_ATTR_IEEE_PFC] && ops->ieee_setpfc) {
- struct ieee_pfc *pfc = nla_data(ieee[DCB_ATTR_IEEE_PFC]);
- err = ops->ieee_setpfc(netdev, pfc);
- if (err)
- goto err;
- }
-
- if (ieee[DCB_ATTR_IEEE_APP_TABLE]) {
- struct nlattr *attr;
- int rem;
-
- nla_for_each_nested(attr, ieee[DCB_ATTR_IEEE_APP_TABLE], rem) {
- struct dcb_app *app_data;
- if (nla_type(attr) != DCB_ATTR_IEEE_APP)
- continue;
- app_data = nla_data(attr);
- if (ops->ieee_setapp)
- err = ops->ieee_setapp(netdev, app_data);
- else
- err = dcb_setapp(netdev, app_data);
- if (err)
- goto err;
- }
- }
-
-err:
- dcbnl_reply(err, RTM_SETDCB, DCB_CMD_IEEE_SET, DCB_ATTR_IEEE,
- pid, seq, flags);
- return err;
-}
-
static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb,
int app_nested_type, int app_info_type,
int app_entry_type)
@@ -1279,30 +1221,13 @@ nla_put_failure:
}
/* Handle IEEE 802.1Qaz GET commands. */
-static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
- u32 pid, u32 seq, u16 flags)
+static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
{
- struct sk_buff *skb;
- struct nlmsghdr *nlh;
- struct dcbmsg *dcb;
struct nlattr *ieee, *app;
struct dcb_app_type *itr;
const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
int dcbx;
- int err;
-
- if (!ops)
- return -EOPNOTSUPP;
-
- skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
- if (!skb)
- return -ENOBUFS;
-
- nlh = NLMSG_NEW(skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags);
-
- dcb = NLMSG_DATA(nlh);
- dcb->dcb_family = AF_UNSPEC;
- dcb->cmd = DCB_CMD_IEEE_GET;
+ int err = -EMSGSIZE;
NLA_PUT_STRING(skb, DCB_ATTR_IFNAME, netdev->name);
@@ -1378,16 +1303,154 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
if (err)
goto nla_put_failure;
}
- nlmsg_end(skb, nlh);
- return rtnl_unicast(skb, &init_net, pid);
+ return 0;
+
nla_put_failure:
- nlmsg_cancel(skb, nlh);
-nlmsg_failure:
- kfree_skb(skb);
- return -1;
+ return err;
}
+int dcbnl_notify(struct net_device *dev, int event, int cmd,
+ u32 seq, u32 pid)
+{
+ struct net *net = dev_net(dev);
+ struct sk_buff *skb;
+ struct nlmsghdr *nlh;
+ struct dcbmsg *dcb;
+ const struct dcbnl_rtnl_ops *ops = dev->dcbnl_ops;
+ int err;
+
+ if (!ops)
+ return -EOPNOTSUPP;
+
+ skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ if (!skb)
+ return -ENOBUFS;
+
+ nlh = nlmsg_put(skb, pid, 0, event, sizeof(*dcb), 0);
+ if (nlh == NULL) {
+ kfree(skb);
+ return -EMSGSIZE;
+ }
+
+ dcb = NLMSG_DATA(nlh);
+ dcb->dcb_family = AF_UNSPEC;
+ dcb->cmd = cmd;
+
+ err = dcbnl_ieee_fill(skb, dev);
+ if (err < 0) {
+ /* Report error to broadcast listeners */
+ nlmsg_cancel(skb, nlh);
+ kfree_skb(skb);
+ rtnl_set_sk_err(net, RTNLGRP_DCB, err);
+ } else {
+ /* End nlmsg and notify broadcast listeners */
+ nlmsg_end(skb, nlh);
+ rtnl_notify(skb, net, 0, RTNLGRP_DCB, NULL, GFP_KERNEL);
+ }
+
+ return err;
+}
+EXPORT_SYMBOL(dcbnl_notify);
+
+/* Handle IEEE 802.1Qaz SET commands. If any requested operation can not
+ * be completed the entire msg is aborted and error value is returned.
+ * No attempt is made to reconcile the case where only part of the
+ * cmd can be completed.
+ */
+static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
+ u32 pid, u32 seq, u16 flags)
+{
+ const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
+ struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1];
+ int err = -EOPNOTSUPP;
+
+ if (!ops)
+ return err;
+
+ err = nla_parse_nested(ieee, DCB_ATTR_IEEE_MAX,
+ tb[DCB_ATTR_IEEE], dcbnl_ieee_policy);
+ if (err)
+ return err;
+
+ if (ieee[DCB_ATTR_IEEE_ETS] && ops->ieee_setets) {
+ struct ieee_ets *ets = nla_data(ieee[DCB_ATTR_IEEE_ETS]);
+ err = ops->ieee_setets(netdev, ets);
+ if (err)
+ goto err;
+ }
+
+ if (ieee[DCB_ATTR_IEEE_PFC] && ops->ieee_setpfc) {
+ struct ieee_pfc *pfc = nla_data(ieee[DCB_ATTR_IEEE_PFC]);
+ err = ops->ieee_setpfc(netdev, pfc);
+ if (err)
+ goto err;
+ }
+
+ if (ieee[DCB_ATTR_IEEE_APP_TABLE]) {
+ struct nlattr *attr;
+ int rem;
+
+ nla_for_each_nested(attr, ieee[DCB_ATTR_IEEE_APP_TABLE], rem) {
+ struct dcb_app *app_data;
+ if (nla_type(attr) != DCB_ATTR_IEEE_APP)
+ continue;
+ app_data = nla_data(attr);
+ if (ops->ieee_setapp)
+ err = ops->ieee_setapp(netdev, app_data);
+ else
+ err = dcb_setapp(netdev, app_data);
+ if (err)
+ goto err;
+ }
+ }
+
+err:
+ dcbnl_reply(err, RTM_SETDCB, DCB_CMD_IEEE_SET, DCB_ATTR_IEEE,
+ pid, seq, flags);
+ dcbnl_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_SET, seq, 0);
+ return err;
+}
+
+static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
+ u32 pid, u32 seq, u16 flags)
+{
+ struct net *net = dev_net(netdev);
+ struct sk_buff *skb;
+ struct nlmsghdr *nlh;
+ struct dcbmsg *dcb;
+ const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
+ int err;
+
+ if (!ops)
+ return -EOPNOTSUPP;
+
+ skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ if (!skb)
+ return -ENOBUFS;
+
+ nlh = nlmsg_put(skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags);
+ if (nlh == NULL) {
+ kfree(skb);
+ return -EMSGSIZE;
+ }
+
+ dcb = NLMSG_DATA(nlh);
+ dcb->dcb_family = AF_UNSPEC;
+ dcb->cmd = DCB_CMD_IEEE_GET;
+
+ err = dcbnl_ieee_fill(skb, netdev);
+
+ if (err < 0) {
+ nlmsg_cancel(skb, nlh);
+ kfree_skb(skb);
+ } else {
+ nlmsg_end(skb, nlh);
+ err = rtnl_unicast(skb, net, pid);
+ }
+
+ return err;
+}
/* DCBX configuration */
static int dcbnl_getdcbx(struct net_device *netdev, struct nlattr **tb,
u32 pid, u32 seq, u16 flags)
^ permalink raw reply related
* [net-next PATCH v2 3/7] dcb: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data
From: John Fastabend @ 2011-06-21 17:34 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
In-Reply-To: <20110621173431.2777.39482.stgit@jf-dev1-dcblab>
This adds a setapp routine for IEEE802.1Qaz encoded APP data types.
The IEEE 802.1Qaz spec encodes the priority bits differently and
allows for multiple APP data entries of the same selector and
protocol. Trying to force these to use the same set routines was
becoming tedious. Furthermore, userspace could probably enforce
the correct semantics, but expecting drivers to do this seems
error prone in the firmware case.
For these reasons add ieee_dcb_setapp() that understands the
IEEE 802.1Qaz encoded form.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/net/dcbnl.h | 1 +
net/dcb/dcbnl.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index b3cf10d..c53a4e0 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -30,6 +30,7 @@ struct dcb_app_type {
u8 dcb_setapp(struct net_device *, struct dcb_app *);
u8 dcb_getapp(struct net_device *, struct dcb_app *);
+int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index ffba326..3e3b51c 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1399,7 +1399,7 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
if (ops->ieee_setapp)
err = ops->ieee_setapp(netdev, app_data);
else
- err = dcb_setapp(netdev, app_data);
+ err = dcb_ieee_setapp(netdev, app_data);
if (err)
goto err;
}
@@ -1829,10 +1829,11 @@ u8 dcb_getapp(struct net_device *dev, struct dcb_app *app)
EXPORT_SYMBOL(dcb_getapp);
/**
- * ixgbe_dcbnl_setapp - add dcb application data to app list
+ * dcb_setapp - add CEE dcb application data to app list
*
- * Priority 0 is the default priority this removes applications
- * from the app list if the priority is set to zero.
+ * Priority 0 is an invalid priority in CEE spec. This routine
+ * removes applications from the app list if the priority is
+ * set to zero.
*/
u8 dcb_setapp(struct net_device *dev, struct dcb_app *new)
{
@@ -1877,6 +1878,52 @@ out:
}
EXPORT_SYMBOL(dcb_setapp);
+/**
+ * dcb_ieee_setapp - add IEEE dcb application data to app list
+ *
+ * This adds Application data to the list. Multiple application
+ * entries may exists for the same selector and protocol as long
+ * as the priorities are different.
+ */
+int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
+{
+ struct dcb_app_type *itr, *entry;
+ struct dcb_app_type event;
+ int err = 0;
+
+ memcpy(&event.name, dev->name, sizeof(event.name));
+ memcpy(&event.app, new, sizeof(event.app));
+
+ spin_lock(&dcb_lock);
+ /* Search for existing match and abort if found */
+ list_for_each_entry(itr, &dcb_app_list, list) {
+ if (itr->app.selector == new->selector &&
+ itr->app.protocol == new->protocol &&
+ itr->app.priority == new->priority &&
+ (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+ err = -EEXIST;
+ goto out;
+ }
+ }
+
+ /* App entry does not exist add new entry */
+ entry = kmalloc(sizeof(struct dcb_app_type), GFP_ATOMIC);
+ if (!entry) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ memcpy(&entry->app, new, sizeof(*new));
+ strncpy(entry->name, dev->name, IFNAMSIZ);
+ list_add(&entry->list, &dcb_app_list);
+out:
+ spin_unlock(&dcb_lock);
+ if (!err)
+ call_dcbevent_notifiers(DCB_APP_EVENT, &event);
+ return err;
+}
+EXPORT_SYMBOL(dcb_ieee_setapp);
+
static void dcb_flushapp(void)
{
struct dcb_app_type *app;
^ permalink raw reply related
* [net-next PATCH v2 4/7] dcb: Add ieee_dcb_delapp() and dcb op to delete app entry
From: John Fastabend @ 2011-06-21 17:34 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
In-Reply-To: <20110621173431.2777.39482.stgit@jf-dev1-dcblab>
Now that we allow multiple IEEE App entries we need a way
to remove specific entries. To do this add the ieee_dcb_delapp()
routine.
Additionaly drivers may need to remove the APP entry from
their firmware tables. Add dcb ops routine to handle this.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/linux/dcbnl.h | 2 +
include/net/dcbnl.h | 2 +
net/dcb/dcbnl.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 92 insertions(+), 2 deletions(-)
diff --git a/include/linux/dcbnl.h b/include/linux/dcbnl.h
index c522800..66a6723 100644
--- a/include/linux/dcbnl.h
+++ b/include/linux/dcbnl.h
@@ -203,6 +203,7 @@ struct dcbmsg {
* @DCB_CMD_GFEATCFG: get DCBX features flags
* @DCB_CMD_SFEATCFG: set DCBX features negotiation flags
* @DCB_CMD_CEE_GET: get CEE aggregated configuration
+ * @DCB_CMD_IEEE_DEL: delete IEEE 802.1Qaz configuration
*/
enum dcbnl_commands {
DCB_CMD_UNDEFINED,
@@ -246,6 +247,7 @@ enum dcbnl_commands {
DCB_CMD_SFEATCFG,
DCB_CMD_CEE_GET,
+ DCB_CMD_IEEE_DEL,
__DCB_CMD_ENUM_MAX,
DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1,
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index c53a4e0..62a2685 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -31,6 +31,7 @@ struct dcb_app_type {
u8 dcb_setapp(struct net_device *, struct dcb_app *);
u8 dcb_getapp(struct net_device *, struct dcb_app *);
int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
+int dcb_ieee_delapp(struct net_device *, struct dcb_app *);
int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);
@@ -46,6 +47,7 @@ struct dcbnl_rtnl_ops {
int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *);
int (*ieee_getapp) (struct net_device *, struct dcb_app *);
int (*ieee_setapp) (struct net_device *, struct dcb_app *);
+ int (*ieee_delapp) (struct net_device *, struct dcb_app *);
int (*ieee_peer_getets) (struct net_device *, struct ieee_ets *);
int (*ieee_peer_getpfc) (struct net_device *, struct ieee_pfc *);
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 3e3b51c..196084f 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1451,6 +1451,52 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
return err;
}
+
+static int dcbnl_ieee_del(struct net_device *netdev, struct nlattr **tb,
+ u32 pid, u32 seq, u16 flags)
+{
+ const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
+ struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1];
+ int err = -EOPNOTSUPP;
+
+ if (!ops)
+ return -EOPNOTSUPP;
+
+ if (!tb[DCB_ATTR_IEEE])
+ return -EINVAL;
+
+ err = nla_parse_nested(ieee, DCB_ATTR_IEEE_MAX,
+ tb[DCB_ATTR_IEEE], dcbnl_ieee_policy);
+ if (err)
+ return err;
+
+ if (ieee[DCB_ATTR_IEEE_APP_TABLE]) {
+ struct nlattr *attr;
+ int rem;
+
+ nla_for_each_nested(attr, ieee[DCB_ATTR_IEEE_APP_TABLE], rem) {
+ struct dcb_app *app_data;
+
+ if (nla_type(attr) != DCB_ATTR_IEEE_APP)
+ continue;
+ app_data = nla_data(attr);
+ if (ops->ieee_delapp)
+ err = ops->ieee_delapp(netdev, app_data);
+ else
+ err = dcb_ieee_delapp(netdev, app_data);
+ if (err)
+ goto err;
+ }
+ }
+
+err:
+ dcbnl_reply(err, RTM_SETDCB, DCB_CMD_IEEE_DEL, DCB_ATTR_IEEE,
+ pid, seq, flags);
+ dcbnl_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_DEL, seq, 0);
+ return err;
+}
+
+
/* DCBX configuration */
static int dcbnl_getdcbx(struct net_device *netdev, struct nlattr **tb,
u32 pid, u32 seq, u16 flags)
@@ -1765,11 +1811,15 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
goto out;
case DCB_CMD_IEEE_SET:
ret = dcbnl_ieee_set(netdev, tb, pid, nlh->nlmsg_seq,
- nlh->nlmsg_flags);
+ nlh->nlmsg_flags);
goto out;
case DCB_CMD_IEEE_GET:
ret = dcbnl_ieee_get(netdev, tb, pid, nlh->nlmsg_seq,
- nlh->nlmsg_flags);
+ nlh->nlmsg_flags);
+ goto out;
+ case DCB_CMD_IEEE_DEL:
+ ret = dcbnl_ieee_del(netdev, tb, pid, nlh->nlmsg_seq,
+ nlh->nlmsg_flags);
goto out;
case DCB_CMD_GDCBX:
ret = dcbnl_getdcbx(netdev, tb, pid, nlh->nlmsg_seq,
@@ -1924,6 +1974,42 @@ out:
}
EXPORT_SYMBOL(dcb_ieee_setapp);
+/**
+ * dcb_ieee_delapp - delete IEEE dcb application data from list
+ *
+ * This removes a matching APP data from the APP list
+ */
+int dcb_ieee_delapp(struct net_device *dev, struct dcb_app *del)
+{
+ struct dcb_app_type *itr;
+ struct dcb_app_type event;
+ int err = -ENOENT;
+
+ memcpy(&event.name, dev->name, sizeof(event.name));
+ memcpy(&event.app, del, sizeof(event.app));
+
+ spin_lock(&dcb_lock);
+ /* Search for existing match and remove it. */
+ list_for_each_entry(itr, &dcb_app_list, list) {
+ if (itr->app.selector == del->selector &&
+ itr->app.protocol == del->protocol &&
+ itr->app.priority == del->priority &&
+ (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+ list_del(&itr->list);
+ kfree(itr);
+ err = 0;
+ goto out;
+ }
+ }
+
+out:
+ spin_unlock(&dcb_lock);
+ if (!err)
+ call_dcbevent_notifiers(DCB_APP_EVENT, &event);
+ return err;
+}
+EXPORT_SYMBOL(dcb_ieee_delapp);
+
static void dcb_flushapp(void)
{
struct dcb_app_type *app;
^ permalink raw reply related
* [net-next PATCH v2 5/7] dcb: Add dcb_ieee_getapp_mask() for drivers to query APP settings
From: John Fastabend @ 2011-06-21 17:34 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
In-Reply-To: <20110621173431.2777.39482.stgit@jf-dev1-dcblab>
With multiple APP entries per selector and protocol drivers
or stacks may want to pick a specific value or stripe traffic
across many priorities. Also if an APP entry in use is
deleted the stack/driver may want to choose from the existing
APP entries.
To facilitate this and avoid having duplicate code to walk
the APP ring provide a routine dcb_ieee_getapp_mask() to
return a u8 bitmask of all priorities set for the specified
selector and protocol. This routine and bitmask is a helper
for DCB kernel users.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/net/dcbnl.h | 1 +
net/dcb/dcbnl.c | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index 62a2685..c14fd94 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -32,6 +32,7 @@ u8 dcb_setapp(struct net_device *, struct dcb_app *);
u8 dcb_getapp(struct net_device *, struct dcb_app *);
int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
int dcb_ieee_delapp(struct net_device *, struct dcb_app *);
+u8 dcb_ieee_getapp_mask(struct net_device *, struct dcb_app *);
int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 196084f..b7d0be0 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1929,6 +1929,32 @@ out:
EXPORT_SYMBOL(dcb_setapp);
/**
+ * dcb_ieee_getapp_mask - retrieve the IEEE DCB application priority
+ *
+ * Helper routine which on success returns a non-zero 802.1Qaz user
+ * priority bitmap otherwise returns 0 to indicate the dcb_app was
+ * not found in APP list.
+ */
+u8 dcb_ieee_getapp_mask(struct net_device *dev, struct dcb_app *app)
+{
+ struct dcb_app_type *itr;
+ u8 prio = 0;
+
+ spin_lock(&dcb_lock);
+ list_for_each_entry(itr, &dcb_app_list, list) {
+ if (itr->app.selector == app->selector &&
+ itr->app.protocol == app->protocol &&
+ (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+ prio |= 1 << itr->app.priority;
+ }
+ }
+ spin_unlock(&dcb_lock);
+
+ return prio;
+}
+EXPORT_SYMBOL(dcb_ieee_getapp_mask);
+
+/**
* dcb_ieee_setapp - add IEEE dcb application data to app list
*
* This adds Application data to the list. Multiple application
^ permalink raw reply related
* [net-next PATCH v2 6/7] dcb: fix return type on dcb_setapp()
From: John Fastabend @ 2011-06-21 17:34 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
In-Reply-To: <20110621173431.2777.39482.stgit@jf-dev1-dcblab>
Incorrect return type on dcb_setapp() this routine
returns negative error codes. All call sites of
dcb_setapp() assign the return value to an int already
so no need to update drivers.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/net/dcbnl.h | 2 +-
net/dcb/dcbnl.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index c14fd94..d5bbb79 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -28,7 +28,7 @@ struct dcb_app_type {
struct list_head list;
};
-u8 dcb_setapp(struct net_device *, struct dcb_app *);
+int dcb_setapp(struct net_device *, struct dcb_app *);
u8 dcb_getapp(struct net_device *, struct dcb_app *);
int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
int dcb_ieee_delapp(struct net_device *, struct dcb_app *);
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index b7d0be0..f54c784 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1885,7 +1885,7 @@ EXPORT_SYMBOL(dcb_getapp);
* removes applications from the app list if the priority is
* set to zero.
*/
-u8 dcb_setapp(struct net_device *dev, struct dcb_app *new)
+int dcb_setapp(struct net_device *dev, struct dcb_app *new)
{
struct dcb_app_type *itr;
struct dcb_app_type event;
^ permalink raw reply related
* [net-next PATCH v2 7/7] dcb: Add missing error check in dcb_ieee_set()
From: John Fastabend @ 2011-06-21 17:35 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
In-Reply-To: <20110621173431.2777.39482.stgit@jf-dev1-dcblab>
Missing error checking before nla_parse_nested().
Reported-by: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
net/dcb/dcbnl.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index f54c784..e954d4c 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1368,6 +1368,9 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
if (!ops)
return err;
+ if (!tb[DCB_ATTR_IEEE])
+ return -EINVAL;
+
err = nla_parse_nested(ieee, DCB_ATTR_IEEE_MAX,
tb[DCB_ATTR_IEEE], dcbnl_ieee_policy);
if (err)
^ permalink raw reply related
* Re: [PATCH] gianfar v5: implement nfc
From: Joe Perches @ 2011-06-21 17:44 UTC (permalink / raw)
To: Sebastian Pöhn; +Cc: Linux Netdev, Sebastian Pöhn
In-Reply-To: <1308562782.12794.6.camel@DENEC1DT0191>
On Mon, 2011-06-20 at 11:39 +0200, Sebastian Pöhn wrote:
> This patch adds all missing functionalities for nfc except GRXFH. There is so much code because hardware has not a TCAM.
> Further hardware rule space is very limited. So I had to extensively use
> optimization features. Both reasons lead to the necessity to hold all
> online flows in a linked-list.
> Signed-off-by: Sebastian Poehn <sebastian.poehn@belden.com>
Just a bit more trivia...
[]
> +/* Swaps the 0xFF80 masked bits of a1<>a2 and b1<>b2 */
> +static void gfar_swap_ff80_bits(struct gfar_filer_entry *a1,
> + struct gfar_filer_entry *a2, struct gfar_filer_entry *b1,
> + struct gfar_filer_entry *b2)
> +{
> + u32 temp[4];
> + temp[0] = a1->ctrl & 0xFF80;
> + temp[1] = a2->ctrl & 0xFF80;
> + temp[2] = b1->ctrl & 0xFF80;
> + temp[3] = b2->ctrl & 0xFF80;
> +
> + a1->ctrl &= ~0xFF80;
> + a2->ctrl &= ~0xFF80;
> + b1->ctrl &= ~0xFF80;
> + b2->ctrl &= ~0xFF80;
> +
> + a1->ctrl |= temp[1];
> + a2->ctrl |= temp[0];
> + b1->ctrl |= temp[3];
> + b2->ctrl |= temp[2];
> +}
maybe add a macro similar to swap:
#define swap_bits(a, b, bits) \
do { \
typeof(a) _bits = bits; \
typeof(a) _a_bits = (a) & _bits; \
typeof(a) _b_bits = (b) & _bits; \
\
(a) &= ~_bits; \
(b) &= ~_bits; \
\
(a) |= _b_bits; \
(b) |= _a_bits; \
} while (0)
and use this macro directly in gfar_sort_mask_table?
swap_bits(temp_table->fe[new_first],
temp_table->fe[old_first], 0xff80);
swap_bits(temp_table->fe[new_last],
temp_table->fe[old_last], 0xff80);
And maybe 0xff80 should be a #define?
^ permalink raw reply
* Re: [RFC 1/7] netdev: add standardized irq naming function
From: Ben Hutchings @ 2011-06-21 17:48 UTC (permalink / raw)
To: Michał Mirosław; +Cc: Stephen Hemminger, davem, netdev
In-Reply-To: <BANLkTi=b89+C=-fnJuacKTKZXBYYouNK=w@mail.gmail.com>
On Tue, 2011-06-21 at 19:30 +0200, Michał Mirosław wrote:
> 2011/6/21 Stephen Hemminger <shemminger@vyatta.com>:
> > To force driver developers to use a standard convention for naming
> > network device IRQ's, provide a standardized method for creating
> > the name.
>
> Can this be modified to track netdev renames?
We should handle renames somehow.
sfc currently uses a netdev notifier to update the names of its IRQs
(and MTDs) but it might make more sense to add something to
net_device_ops rather than having every driver receive notification for
every device.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [RFC 1/7] netdev: add standardized irq naming function
From: Stephen Hemminger @ 2011-06-21 17:56 UTC (permalink / raw)
To: Ben Hutchings; +Cc: Michał Mirosław, davem, netdev
In-Reply-To: <1308678535.2743.27.camel@bwh-desktop>
On Tue, 21 Jun 2011 18:48:55 +0100
Ben Hutchings <bhutchings@solarflare.com> wrote:
> On Tue, 2011-06-21 at 19:30 +0200, Michał Mirosław wrote:
> > 2011/6/21 Stephen Hemminger <shemminger@vyatta.com>:
> > > To force driver developers to use a standard convention for naming
> > > network device IRQ's, provide a standardized method for creating
> > > the name.
> >
> > Can this be modified to track netdev renames?
>
> We should handle renames somehow.
>
> sfc currently uses a netdev notifier to update the names of its IRQs
> (and MTDs) but it might make more sense to add something to
> net_device_ops rather than having every driver receive notification for
> every device.
>
> Ben.
>
Since renames are only allowed when netdevice is down.
Renames do not need to be tracked if device registers irq in open
handler.
^ permalink raw reply
* [PATCH v2] netconsole: fix build when CONFIG_NETCONSOLE_DYNAMIC is turned on
From: Randy Dunlap @ 2011-06-21 18:01 UTC (permalink / raw)
To: Ben Hutchings, Andrew Morton, davem; +Cc: netdev, bugme-daemon, hilld
In-Reply-To: <1308660309.3093.108.camel@localhost>
From: Randy Dunlap <randy.dunlap@oracle.com>
When NETCONSOLE_DYNAMIC=y and CONFIGFS_FS=m, there are build errors
in netconsole:
drivers/built-in.o: In function `drop_netconsole_target':
netconsole.c:(.text+0x1a100f): undefined reference to `config_item_put'
drivers/built-in.o: In function `make_netconsole_target':
netconsole.c:(.text+0x1a10b9): undefined reference to `config_item_init_type_name'
drivers/built-in.o: In function `write_msg':
netconsole.c:(.text+0x1a11a4): undefined reference to `config_item_get'
netconsole.c:(.text+0x1a1211): undefined reference to `config_item_put'
drivers/built-in.o: In function `netconsole_netdev_event':
netconsole.c:(.text+0x1a12cc): undefined reference to `config_item_put'
netconsole.c:(.text+0x1a12ec): undefined reference to `config_item_get'
netconsole.c:(.text+0x1a1366): undefined reference to `config_item_put'
drivers/built-in.o: In function `init_netconsole':
netconsole.c:(.init.text+0x953a): undefined reference to `config_group_init'
netconsole.c:(.init.text+0x9560): undefined reference to `configfs_register_subsystem'
drivers/built-in.o: In function `dynamic_netconsole_exit':
netconsole.c:(.exit.text+0x809): undefined reference to `configfs_unregister_subsystem'
so fix the NETCONSOLE_DYNAMIC depends clause to prevent this.
Based on email suggestion from Ben Hutchings. Thanks.
Fixes https://bugzilla.kernel.org/show_bug.cgi?id=37992
Reported-by: David Hill <hilld@binarystorm.net>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/Kconfig | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- lnx-30-rc3.orig/drivers/net/Kconfig
+++ lnx-30-rc3/drivers/net/Kconfig
@@ -3416,7 +3416,8 @@ config NETCONSOLE
config NETCONSOLE_DYNAMIC
bool "Dynamic reconfiguration of logging targets"
- depends on NETCONSOLE && SYSFS && CONFIGFS_FS
+ depends on NETCONSOLE && SYSFS && CONFIGFS_FS && \
+ !(NETCONSOLE=y && CONFIGFS_FS=m)
help
This option enables the ability to dynamically reconfigure target
parameters (interface, IP addresses, port numbers, MAC addresses)
^ permalink raw reply
* Re: [RFC 1/7] netdev: add standardized irq naming function
From: Ben Hutchings @ 2011-06-21 18:07 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: davem, netdev
In-Reply-To: <20110621170658.395370414@vyatta.com>
On Tue, 2011-06-21 at 10:05 -0700, Stephen Hemminger wrote:
> To force driver developers to use a standard convention for naming
> network device IRQ's, provide a standardized method for creating
> the name.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
>
> --- a/include/linux/netdevice.h 2011-06-21 08:58:32.207953328 -0700
> +++ b/include/linux/netdevice.h 2011-06-21 09:12:12.155952869 -0700
> @@ -2631,6 +2631,46 @@ static inline const char *netdev_name(co
> return dev->name;
> }
>
> +/* function bits for netdev_irqname */
> +#define NETIF_IRQ_TX 1
> +#define NETIF_IRQ_RX 2
> +#define NETIF_IRQ_TXRX 3
> +#define NETIF_IRQ_OTHER 0 /* none of the above */
There can be multiple 'other' IRQs in which case they will need their
own suffixes.
Also: 'netdev' and 'NETIF'? We are terribly inconsistent about this but
we could at least make this single change self-consistent. :-)
> +/**
> + * netdev_irqname - generate name for irq
> + * @buf: space to store result
> + * @buflen: sizeof buf
> + * @dev: network device
> + * @queue: assoctiated network queue
Queue index.
> + * @function: function of irq
> + *
> + * Format a IRQ name according to standard convention to be passed
> + * to request_irq().
> + */
> +static inline const char *netdev_irqname(char *buf, size_t buflen,
> + const struct net_device *dev,
> + unsigned queue,
> + unsigned function)
Might be worth making this a little more generic as storage devices are
also going multiqueue in a similar way.
> +{
> + switch (function) {
> + case NETIF_IRQ_TX:
> + snprintf(buf, buflen, "%s-tx-%u", dev->name, queue);
> + break;
> + case NETIF_IRQ_RX:
> + snprintf(buf, buflen, "%s-rx-%u", dev->name, queue);
> + break;
> + case NETIF_IRQ_TXRX:
> + snprintf(buf, buflen, "%s-%u", dev->name, queue);
> + break;
> + default:
> + snprintf(buf, buflen, "%s", dev->name);
> + }
> +
> + return buf;
> +}
So perhaps something like:
/* kernel/irq/manage.c */
const char *irq_name(char *buf, size_t buflen, const char *base_name,
int index, const char *type)
{
if (type) {
if (index >= 0)
snprintf(buf, buflen, "%s-%s-%d", base_name, type, index);
else
snprintf(buf, buflen, "%s-%s", base_name, type);
} else {
if (index >= 0)
snprintf(buf, buflen, "%s-%d", base_name, index);
else
strlcpy(buf, base_name, buflen);
}
return buf;
}
/* include/linux/interrupt.h */
#define IRQ_NAME_NO_INDEX (-1)
/* include/linux/netdevice.h */
/* IRQ type name for netdev_irqname */
#define NETDEV_IRQ_TYPE_TX "tx"
#define NETDEV_IRQ_TYPE_RX "rx"
#define NETDEV_IRQ_TYPE_TXRX NULL
/**
* netdev_irqname - generate name for irq
* @buf: space to store result
* @buflen: sizeof buf
* @dev: network device
* @index: network queue index
* @type: type of IRQ
*
* Format a IRQ name according to standard convention to be passed
* to request_irq().
*/
static inline const char *netdev_irqname(char *buf, size_t buflen,
const struct net_device *dev,
int index, const char *type)
{
return irq_name(buf, buflen, dev->name, index, type);
}
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [RFC 5/7] bnx2: use netdev_irqname
From: Ben Hutchings @ 2011-06-21 18:11 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: davem, netdev
In-Reply-To: <20110621170658.788401517@vyatta.com>
On Tue, 2011-06-21 at 10:05 -0700, Stephen Hemminger wrote:
> Also increase size of irq name to account for longer device names.
> Original code was broken for full size names.
[...]
We should define a macro for the maximum netdev IRQ name length. I
think this would be IFNAMSIZ + 1 + 2 + 1 + 5 (2 characters for queue
type; up to 5 digits for 16-bit queue index).
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [RFC 5/7] bnx2: use netdev_irqname
From: Stephen Hemminger @ 2011-06-21 18:17 UTC (permalink / raw)
To: Ben Hutchings; +Cc: davem, netdev
In-Reply-To: <1308679911.2743.45.camel@bwh-desktop>
On Tue, 21 Jun 2011 19:11:51 +0100
Ben Hutchings <bhutchings@solarflare.com> wrote:
> On Tue, 2011-06-21 at 10:05 -0700, Stephen Hemminger wrote:
>
> > Also increase size of irq name to account for longer device names.
> > Original code was broken for full size names.
> [...]
>
> We should define a macro for the maximum netdev IRQ name length. I
> think this would be IFNAMSIZ + 1 + 2 + 1 + 5 (2 characters for queue
> type; up to 5 digits for 16-bit queue index).
>
> Ben.
>
Probably should put it in the queue structures?
^ permalink raw reply
* [PATCH v2 net-next] ip: introduce ip_is_fragment helper inline function
From: Paul Gortmaker @ 2011-06-21 18:25 UTC (permalink / raw)
To: davem; +Cc: netdev, bhutchings, Paul Gortmaker
There are enough instances of this:
iph->frag_off & htons(IP_MF | IP_OFFSET)
that a helper function is probably warranted.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
v2: fix pre-existing ==0 style issues; change new fcn from int to bool
drivers/net/bonding/bond_main.c | 2 +-
drivers/net/ioc3-eth.c | 2 +-
drivers/net/myri10ge/myri10ge.c | 2 +-
drivers/net/s2io.c | 2 +-
drivers/net/sfc/filter.c | 2 +-
drivers/net/vxge/vxge-main.c | 2 +-
include/net/ip.h | 5 +++++
net/core/dev.c | 2 +-
net/ipv4/ip_input.c | 4 ++--
net/ipv4/ip_output.c | 2 +-
net/ipv4/ipconfig.c | 2 +-
net/ipv4/netfilter/nf_defrag_ipv4.c | 2 +-
net/ipv4/netfilter/nf_nat_standalone.c | 2 +-
net/ipv4/xfrm4_policy.c | 2 +-
net/netfilter/ipvs/ip_vs_core.c | 7 +++----
net/sched/cls_flow.c | 4 ++--
net/sched/cls_rsvp.h | 2 +-
net/sched/sch_choke.c | 2 +-
net/sched/sch_sfq.c | 2 +-
19 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 07e866d..5baeb6e 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3432,7 +3432,7 @@ static int bond_xmit_hash_policy_l34(struct sk_buff *skb, int count)
int layer4_xor = 0;
if (skb->protocol == htons(ETH_P_IP)) {
- if (!(iph->frag_off & htons(IP_MF|IP_OFFSET)) &&
+ if (!ip_is_fragment(iph) &&
(iph->protocol == IPPROTO_TCP ||
iph->protocol == IPPROTO_UDP)) {
layer4_xor = ntohs((*layer4hdr ^ *(layer4hdr + 1)));
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index 32f07f8..318a25a 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -532,7 +532,7 @@ static void ioc3_tcpudp_checksum(struct sk_buff *skb, uint32_t hwsum, int len)
return;
ih = (struct iphdr *) ((char *)eh + ETH_HLEN);
- if (ih->frag_off & htons(IP_MF | IP_OFFSET))
+ if (ip_is_fragment(ih))
return;
proto = ih->protocol;
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index 04e10f4..110b61a 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -2257,7 +2257,7 @@ myri10ge_get_frag_header(struct skb_frag_struct *frag, void **mac_hdr,
*ip_hdr = iph;
if (iph->protocol != IPPROTO_TCP)
return -1;
- if (iph->frag_off & htons(IP_MF | IP_OFFSET))
+ if (ip_is_fragment(iph))
return -1;
*hdr_flags |= LRO_TCP;
*tcpudp_hdr = (u8 *) (*ip_hdr) + (iph->ihl << 2);
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index df0d2c8..5e9d644 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -4111,7 +4111,7 @@ static netdev_tx_t s2io_xmit(struct sk_buff *skb, struct net_device *dev)
struct tcphdr *th;
ip = ip_hdr(skb);
- if ((ip->frag_off & htons(IP_OFFSET|IP_MF)) == 0) {
+ if (!ip_is_fragment(ip)) {
th = (struct tcphdr *)(((unsigned char *)ip) +
ip->ihl*4);
diff --git a/drivers/net/sfc/filter.c b/drivers/net/sfc/filter.c
index 95a980f..f2fc258 100644
--- a/drivers/net/sfc/filter.c
+++ b/drivers/net/sfc/filter.c
@@ -652,7 +652,7 @@ int efx_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
/* RFS must validate the IP header length before calling us */
EFX_BUG_ON_PARANOID(!pskb_may_pull(skb, nhoff + sizeof(*ip)));
ip = (const struct iphdr *)(skb->data + nhoff);
- if (ip->frag_off & htons(IP_MF | IP_OFFSET))
+ if (ip_is_fragment(ip))
return -EPROTONOSUPPORT;
EFX_BUG_ON_PARANOID(!pskb_may_pull(skb, nhoff + 4 * ip->ihl + 4));
ports = (const __be16 *)(skb->data + nhoff + 4 * ip->ihl);
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
index e658edd..a018ad8 100644
--- a/drivers/net/vxge/vxge-main.c
+++ b/drivers/net/vxge/vxge-main.c
@@ -629,7 +629,7 @@ static u32 vxge_get_vpath_no(struct vxgedev *vdev, struct sk_buff *skb)
ip = ip_hdr(skb);
- if ((ip->frag_off & htons(IP_OFFSET|IP_MF)) == 0) {
+ if (!ip_is_fragment(ip)) {
th = (struct tcphdr *)(((unsigned char *)ip) +
ip->ihl*4);
diff --git a/include/net/ip.h b/include/net/ip.h
index e9ea7c7..d603cd3 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -250,6 +250,11 @@ int ip_decrease_ttl(struct iphdr *iph)
return --iph->ttl;
}
+static inline bool ip_is_fragment(const struct iphdr *iph)
+{
+ return (iph->frag_off & htons(IP_MF | IP_OFFSET)) != 0;
+}
+
static inline
int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
{
diff --git a/net/core/dev.c b/net/core/dev.c
index b3f52d2..5bb00d5 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2532,7 +2532,7 @@ __u32 __skb_get_rxhash(struct sk_buff *skb)
goto done;
ip = (const struct iphdr *) (skb->data + nhoff);
- if (ip->frag_off & htons(IP_MF | IP_OFFSET))
+ if (ip_is_fragment(ip))
ip_proto = 0;
else
ip_proto = ip->protocol;
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index c8f48ef..073a9b0 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -165,7 +165,7 @@ int ip_call_ra_chain(struct sk_buff *skb)
(!sk->sk_bound_dev_if ||
sk->sk_bound_dev_if == dev->ifindex) &&
net_eq(sock_net(sk), dev_net(dev))) {
- if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
+ if (ip_is_fragment(ip_hdr(skb))) {
if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN))
return 1;
}
@@ -256,7 +256,7 @@ int ip_local_deliver(struct sk_buff *skb)
* Reassemble IP fragments.
*/
- if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
+ if (ip_is_fragment(ip_hdr(skb))) {
if (ip_defrag(skb, IP_DEFRAG_LOCAL_DELIVER))
return 0;
}
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 98af369..529a6f6 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -489,7 +489,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
if (first_len - hlen > mtu ||
((first_len - hlen) & 7) ||
- (iph->frag_off & htons(IP_MF|IP_OFFSET)) ||
+ ip_is_fragment(iph) ||
skb_cloned(skb))
goto slow_path;
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index ab7e554..ae93dd5 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -932,7 +932,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
goto drop;
/* Fragments are not supported */
- if (h->frag_off & htons(IP_OFFSET | IP_MF)) {
+ if (ip_is_fragment(h)) {
if (net_ratelimit())
printk(KERN_ERR "DHCP/BOOTP: Ignoring fragmented "
"reply.\n");
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c
index f3a9b42..9bb1b8a 100644
--- a/net/ipv4/netfilter/nf_defrag_ipv4.c
+++ b/net/ipv4/netfilter/nf_defrag_ipv4.c
@@ -82,7 +82,7 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
#endif
#endif
/* Gather fragments. */
- if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
+ if (ip_is_fragment(ip_hdr(skb))) {
enum ip_defrag_users user = nf_ct_defrag_user(hooknum, skb);
if (nf_ct_ipv4_gather_frags(skb, user))
return NF_STOLEN;
diff --git a/net/ipv4/netfilter/nf_nat_standalone.c b/net/ipv4/netfilter/nf_nat_standalone.c
index 7317bdf..42c0e45 100644
--- a/net/ipv4/netfilter/nf_nat_standalone.c
+++ b/net/ipv4/netfilter/nf_nat_standalone.c
@@ -88,7 +88,7 @@ nf_nat_fn(unsigned int hooknum,
/* We never see fragments: conntrack defrags on pre-routing
and local-out, and nf_nat_out protects post-routing. */
- NF_CT_ASSERT(!(ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)));
+ NF_CT_ASSERT(!ip_is_fragment(ip_hdr(skb)));
ct = nf_ct_get(skb, &ctinfo);
/* Can't track? It's not due to stress, or conntrack would
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 981e43e..fc5368a 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -117,7 +117,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
memset(fl4, 0, sizeof(struct flowi4));
fl4->flowi4_mark = skb->mark;
- if (!(iph->frag_off & htons(IP_MF | IP_OFFSET))) {
+ if (!ip_is_fragment(iph)) {
switch (iph->protocol) {
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index bfa808f..c965428 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -852,7 +852,7 @@ static int ip_vs_out_icmp(struct sk_buff *skb, int *related,
*related = 1;
/* reassemble IP fragments */
- if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
+ if (ip_is_fragment(ip_hdr(skb))) {
if (ip_vs_gather_frags(skb, ip_vs_defrag_user(hooknum)))
return NF_STOLEN;
}
@@ -1156,8 +1156,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb, int af)
ip_vs_fill_iphdr(af, skb_network_header(skb), &iph);
} else
#endif
- if (unlikely(ip_hdr(skb)->frag_off & htons(IP_MF|IP_OFFSET) &&
- !pp->dont_defrag)) {
+ if (unlikely(ip_is_fragment(ip_hdr(skb)) && !pp->dont_defrag)) {
if (ip_vs_gather_frags(skb,
ip_vs_defrag_user(hooknum)))
return NF_STOLEN;
@@ -1310,7 +1309,7 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)
*related = 1;
/* reassemble IP fragments */
- if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
+ if (ip_is_fragment(ip_hdr(skb))) {
if (ip_vs_gather_frags(skb, ip_vs_defrag_user(hooknum)))
return NF_STOLEN;
}
diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c
index 8ec0139..34533a5 100644
--- a/net/sched/cls_flow.c
+++ b/net/sched/cls_flow.c
@@ -121,7 +121,7 @@ static u32 flow_get_proto_src(struct sk_buff *skb)
if (!pskb_network_may_pull(skb, sizeof(*iph)))
break;
iph = ip_hdr(skb);
- if (iph->frag_off & htons(IP_MF | IP_OFFSET))
+ if (ip_is_fragment(iph))
break;
poff = proto_ports_offset(iph->protocol);
if (poff >= 0 &&
@@ -163,7 +163,7 @@ static u32 flow_get_proto_dst(struct sk_buff *skb)
if (!pskb_network_may_pull(skb, sizeof(*iph)))
break;
iph = ip_hdr(skb);
- if (iph->frag_off & htons(IP_MF | IP_OFFSET))
+ if (ip_is_fragment(iph))
break;
poff = proto_ports_offset(iph->protocol);
if (poff >= 0 &&
diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h
index 402c44b..ed691b1 100644
--- a/net/sched/cls_rsvp.h
+++ b/net/sched/cls_rsvp.h
@@ -167,7 +167,7 @@ restart:
dst = &nhptr->daddr;
protocol = nhptr->protocol;
xprt = ((u8 *)nhptr) + (nhptr->ihl<<2);
- if (nhptr->frag_off & htons(IP_MF | IP_OFFSET))
+ if (ip_is_fragment(nhptr))
return -1;
#endif
diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
index 06afbae..3422b25 100644
--- a/net/sched/sch_choke.c
+++ b/net/sched/sch_choke.c
@@ -181,7 +181,7 @@ static bool choke_match_flow(struct sk_buff *skb1,
ip1->saddr != ip2->saddr || ip1->daddr != ip2->daddr)
return false;
- if ((ip1->frag_off | ip2->frag_off) & htons(IP_MF | IP_OFFSET))
+ if (ip_is_fragment(ip1) | ip_is_fragment(ip2))
ip_proto = 0;
off1 += ip1->ihl * 4;
off2 += ip2->ihl * 4;
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index b6ea6af..4536ee6 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -157,7 +157,7 @@ static unsigned int sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)
iph = ip_hdr(skb);
h = (__force u32)iph->daddr;
h2 = (__force u32)iph->saddr ^ iph->protocol;
- if (iph->frag_off & htons(IP_MF | IP_OFFSET))
+ if (ip_is_fragment(iph))
break;
poff = proto_ports_offset(iph->protocol);
if (poff >= 0 &&
--
1.7.4.4
^ permalink raw reply related
* Re: [PATCH]: Add Network Sysrq Support
From: Neil Horman @ 2011-06-21 18:30 UTC (permalink / raw)
To: Stephen Hemminger
Cc: Prarit Bhargava, netdev, davem, agospoda, nhorman, lwoodman
In-Reply-To: <20110621100858.70c23a93@nehalam.ftrdhcpuser.net>
On Tue, Jun 21, 2011 at 10:08:58AM -0700, Stephen Hemminger wrote:
> On Tue, 21 Jun 2011 09:00:40 -0400
> Prarit Bhargava <prarit@redhat.com> wrote:
>
> > Add Network Sysrq Support
> >
> > In some circumstances, a system can hang/lockup in such a way that the system
> > is completely unresponsive to keyboard or console input but is still
> > responsive to ping. The config option, CONFIG_SYSRQ_PING, builds
> > net/ipv4/sysrq-ping.ko which allows a root user to configure the system for
> > a remote sysrq.
> >
> > To use this do:
> >
> > mount -t debugfs none /sys/kernel/debug/
> > echo 1 > /proc/sys/kernel/sysrq
> > echo <hex digit val> > /sys/kernel/debug/network_sysrq_magic
> > echo 1 > /sys/kernel/debug/network_sysrq_enable
> >
> > Then on another system on the network you can do:
> >
> > ping -c 1 -p <up to 30 hex digit val><hex val of sysrq> <target_system_name>
> >
> > ex) sysrq-m, m is ascii 0x6d
> >
> > ping -c 1 p 1623a06f554d46d676d <target_system_name>
> >
> > Note that the network sysrq automatically disables after the receipt of
> > the ping, ie) it is single-shot mode. If you want to use this again, you
> > must complete the above four steps again.
> >
> > Signed-off-by: Prarit Bhargava <prarit@redhat.com>
>
> Isn't same functionality already available with netconsole?
Negative, netconsole is a unidirectional protocol. It registers no rx_hook and
so it doesn't receive frames. It could be added, and we could add this
functionality that way, but that would seem wierd (to me at least):
1) It would mean that netconsole was writeable, which means we would need a
utility on the remote server to do that writing to the proper udp port
2) Said utility in (1) would have some security concerns, unless we implemented
the exact same magic key sequencing that prarit has here. Otherwise any
attacker could send an unsolicited request to the netconsole port on a system.
I like the idea of keeping this functionality separate from a feature that gets
such wide use in a production environment.
I've hacked this kind of feature together to solve this problem a few times now,
I think it would be good to have it as a well defined feature permanently.
Acked-by: Neil Horman <nhorman@tuxdriver.com>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: [PATCH 1/3] serial/imx: add device tree support
From: Mitch Bradley @ 2011-06-21 18:32 UTC (permalink / raw)
To: Shawn Guo
Cc: patches, netdev, devicetree-discuss, Jason Liu, linux-kernel,
Grant Likely, Jeremy Kerr, Sascha Hauer, linux-arm-kernel
In-Reply-To: <20110621135558.GB9228@S2101-09.ap.freescale.net>
I wonder if it makes sense to create a new device node "/linux-devices" to express a desired mapping from device nodes to /dev entries? The properties could be the names of device special files and the values the corresponding node phandles.
On 6/21/2011 3:55 AM, Shawn Guo wrote:
> Hi Grant,
>
> I just gave a try to use aliases node for identify the device index.
> Please take a look and let me know if it's what you expect.
>
> On Sun, Jun 19, 2011 at 03:30:02PM +0800, Shawn Guo wrote:
> [...]
>>>>
>>>> +#ifdef CONFIG_OF
>>>> +static int serial_imx_probe_dt(struct imx_port *sport,
>>>> + struct platform_device *pdev)
>>>> +{
>>>> + struct device_node *node = pdev->dev.of_node;
>>>> + const __be32 *line;
>>>> +
>>>> + if (!node)
>>>> + return -ENODEV;
>>>> +
>>>> + line = of_get_property(node, "id", NULL);
>>>> + if (!line)
>>>> + return -ENODEV;
>>>> +
>>>> + sport->port.line = be32_to_cpup(line) - 1;
>>>
>>> Hmmm, I really would like to be rid of this. Instead, if uarts must
>>> be enumerated, the driver should look for a /aliases/uart* property
>>> that matches the of_node. Doing it that way is already established in
>>> the OpenFirmware documentation, and it ensures there are no overlaps
>>> in the global namespace.
>>>
>>
>> I just gave one more try to avoid using 'aliases', and you gave a
>> 'no' again. Now, I know how hard you are on this. Okay, I start
>> thinking about your suggestion seriously :)
>>
>>> We do need some infrastructure to make that easier though. Would you
>>> have time to help put that together?
>>>
>> Ok, I will give it a try.
>>
>
> diff --git a/arch/arm/boot/dts/imx51-babbage.dts b/arch/arm/boot/dts/imx51-babbage.dts
> index da0381a..f4a5c3c 100644
> --- a/arch/arm/boot/dts/imx51-babbage.dts
> +++ b/arch/arm/boot/dts/imx51-babbage.dts
> @@ -18,6 +18,12 @@
> compatible = "fsl,imx51-babbage", "fsl,imx51";
> interrupt-parent =<&tzic>;
>
> + aliases {
> + serial0 =&uart0;
> + serial1 =&uart1;
> + serial2 =&uart2;
> + };
> +
> chosen {
> bootargs = "console=ttymxc0,115200 root=/dev/mmcblk0p3 rootwait";
> };
> @@ -47,29 +53,29 @@
> reg =<0x70000000 0x40000>;
> ranges;
>
> - uart@7000c000 {
> + uart2: uart@7000c000 {
> compatible = "fsl,imx51-uart", "fsl,imx21-uart";
> reg =<0x7000c000 0x4000>;
> interrupts =<33>;
> id =<3>;
> - fsl,has-rts-cts;
> + fsl,uart-has-rtscts;
> };
> };
>
> - uart@73fbc000 {
> + uart0: uart@73fbc000 {
> compatible = "fsl,imx51-uart", "fsl,imx21-uart";
> reg =<0x73fbc000 0x4000>;
> interrupts =<31>;
> id =<1>;
> - fsl,has-rts-cts;
> + fsl,uart-has-rtscts;
> };
>
> - uart@73fc0000 {
> + uart1: uart@73fc0000 {
> compatible = "fsl,imx51-uart", "fsl,imx21-uart";
> reg =<0x73fc0000 0x4000>;
> interrupts =<32>;
> id =<2>;
> - fsl,has-rts-cts;
> + fsl,uart-has-rtscts;
> };
> };
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 632ebae..13df5d2 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -737,6 +737,37 @@ err0:
> EXPORT_SYMBOL(of_parse_phandles_with_args);
>
> /**
> + * of_get_device_index - Get device index by looking up "aliases" node
> + * @np: Pointer to device node that asks for device index
> + * @name: The device alias without index number
> + *
> + * Returns the device index if find it, else returns -ENODEV.
> + */
> +int of_get_device_index(struct device_node *np, const char *alias)
> +{
> + struct device_node *aliases = of_find_node_by_name(NULL, "aliases");
> + struct property *prop;
> + char name[32];
> + int index = 0;
> +
> + if (!aliases)
> + return -ENODEV;
> +
> + while (1) {
> + snprintf(name, sizeof(name), "%s%d", alias, index);
> + prop = of_find_property(aliases, name, NULL);
> + if (!prop)
> + return -ENODEV;
> + if (np == of_find_node_by_path(prop->value))
> + break;
> + index++;
> + }
> +
> + return index;
> +}
> +EXPORT_SYMBOL(of_get_device_index);
> +
> +/**
> * prom_add_property - Add a property to a node
> */
> int prom_add_property(struct device_node *np, struct property *prop)
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index da436e0..852668f 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1271,18 +1271,18 @@ static int serial_imx_probe_dt(struct imx_port *sport,
> struct device_node *node = pdev->dev.of_node;
> const struct of_device_id *of_id =
> of_match_device(imx_uart_dt_ids,&pdev->dev);
> - const __be32 *line;
> + int line;
>
> if (!node)
> return -ENODEV;
>
> - line = of_get_property(node, "id", NULL);
> - if (!line)
> + line = of_get_device_index(node, "serial");
> + if (IS_ERR_VALUE(line))
> return -ENODEV;
>
> - sport->port.line = be32_to_cpup(line) - 1;
> + sport->port.line = line;
>
> - if (of_get_property(node, "fsl,has-rts-cts", NULL))
> + if (of_get_property(node, "fsl,uart-has-rtscts", NULL))
> sport->have_rtscts = 1;
>
> if (of_get_property(node, "fsl,irda-mode", NULL))
> diff --git a/include/linux/of.h b/include/linux/of.h
> index bfc0ed1..3153752 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -213,6 +213,8 @@ extern int of_parse_phandles_with_args(struct device_node *np,
> const char *list_name, const char *cells_name, int index,
> struct device_node **out_node, const void **out_args);
>
> +extern int of_get_device_index(struct device_node *np, const char *alias);
> +
> extern int of_machine_is_compatible(const char *compat);
>
> extern int prom_add_property(struct device_node* np, struct property* prop);
>
^ permalink raw reply
* Re: [PATCH 1/3] serial/imx: add device tree support
From: Grant Likely @ 2011-06-21 18:42 UTC (permalink / raw)
To: Mitch Bradley
Cc: Shawn Guo, patches, netdev, devicetree-discuss, Jason Liu,
linux-kernel, Jeremy Kerr, Sascha Hauer, linux-arm-kernel
In-Reply-To: <4E00E3D2.6050602@firmworks.com>
On Tue, Jun 21, 2011 at 12:32 PM, Mitch Bradley <wmb@firmworks.com> wrote:
> I wonder if it makes sense to create a new device node "/linux-devices" to express a desired mapping from device nodes to /dev entries? The properties could be the names of device special files and the values the corresponding node phandles.
I've been trying /really/ hard to avoid doing something like that
because a lot of the time the desired Linux dev name is a
implementation detail, and a potentially unstable one at that. If
Linux requires certain devices to have certain names because that is
how it hooks up clocks (which is the current situation on some
platforms), then I'd rather have Linux encode a lookup of the
preferred name, at least until the that particular implementation
detail goes away.
As for enumerating devices, I don't think this is a Linux-specific
thing. In this case it is entirely reasonable to want to say /this
node/ is the second serial port, and /that node/ is the third, which
is information needed regardless of the client OS.
g.
^ permalink raw reply
* Re: [RFC 5/7] bnx2: use netdev_irqname
From: Ben Hutchings @ 2011-06-21 18:42 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: davem, netdev
In-Reply-To: <20110621111756.5c7541ba@nehalam.ftrdhcpuser.net>
On Tue, 2011-06-21 at 11:17 -0700, Stephen Hemminger wrote:
> On Tue, 21 Jun 2011 19:11:51 +0100
> Ben Hutchings <bhutchings@solarflare.com> wrote:
>
> > On Tue, 2011-06-21 at 10:05 -0700, Stephen Hemminger wrote:
> >
> > > Also increase size of irq name to account for longer device names.
> > > Original code was broken for full size names.
> > [...]
> >
> > We should define a macro for the maximum netdev IRQ name length. I
> > think this would be IFNAMSIZ + 1 + 2 + 1 + 5 (2 characters for queue
> > type; up to 5 digits for 16-bit queue index).
> >
> > Ben.
> >
>
> Probably should put it in the queue structures?
Not really, given an IRQ can be related to multiple queues.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [PATCH net-next V2] drivers/net: Remove casts of void *
From: Joe Perches @ 2011-06-21 18:45 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-kernel
In-Reply-To: <20110617.151903.1203335395245647912.davem@davemloft.net>
On Fri, 2011-06-17 at 15:19 -0400, David Miller wrote:
> From: Joe Perches <joe@perches.com>
> Date: Thu, 16 Jun 2011 22:08:06 -0700
> > Unnecessary casts of void * clutter the code.
> > These are the remainder casts after several specific
> > patches to remove netdev_priv and dev_priv.
> > Done via coccinelle script (and a little editing):
> Applied, thanks.
Unapplied? I don't see this in net-next.
^ permalink raw reply
* Re: [PATCH 1/3] serial/imx: add device tree support
From: Russell King - ARM Linux @ 2011-06-21 18:53 UTC (permalink / raw)
To: Grant Likely
Cc: Mitch Bradley, patches, netdev, devicetree-discuss, Jason Liu,
linux-kernel, linux-arm-kernel, Jeremy Kerr, Sascha Hauer,
Shawn Guo
In-Reply-To: <BANLkTiny9xDwiUww9Ys+jQZ0SHdQATABUA@mail.gmail.com>
On Tue, Jun 21, 2011 at 12:42:14PM -0600, Grant Likely wrote:
> On Tue, Jun 21, 2011 at 12:32 PM, Mitch Bradley <wmb@firmworks.com> wrote:
> > I wonder if it makes sense to create a new device node "/linux-devices" to express a desired mapping from device nodes to /dev entries? The properties could be the names of device special files and the values the corresponding node phandles.
>
> I've been trying /really/ hard to avoid doing something like that
> because a lot of the time the desired Linux dev name is a
> implementation detail, and a potentially unstable one at that. If
> Linux requires certain devices to have certain names because that is
> how it hooks up clocks
As I keep on saying, we don't _have_ to have to match on device name.
If DT can come up with a better way to bind a clock to a particular
device/connection name then DT can provide its own clk_get()
implementation which does that.
clk_get() has the struct device, and therefore can get at the DT
information itself to read out whatever properties are required. But,
we must not get away from the fact that clk_get()'s second argument
should _never_ be used as a unique clock name itself.
At the moment, until we do have some kind of DT based clk_get(), the
easiest way to move clk-API using drivers over is to use the device
name in the static clk_lookup tables.
It's all an implementation detail, one which is (thankfully) hidden
behind a proper API which will be _completely_ transparent to drivers
using the clk API in the _proper_ way.
^ permalink raw reply
* Re: [PATCH 1/3] serial/imx: add device tree support
From: Grant Likely @ 2011-06-21 19:02 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: patches, netdev, devicetree-discuss, Jason Liu, linux-kernel,
Shawn Guo, Mitch Bradley, Jeremy Kerr, Sascha Hauer,
linux-arm-kernel
In-Reply-To: <20110621185356.GJ23234@n2100.arm.linux.org.uk>
On Tue, Jun 21, 2011 at 12:53 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Tue, Jun 21, 2011 at 12:42:14PM -0600, Grant Likely wrote:
>> On Tue, Jun 21, 2011 at 12:32 PM, Mitch Bradley <wmb@firmworks.com> wrote:
>> > I wonder if it makes sense to create a new device node "/linux-devices" to express a desired mapping from device nodes to /dev entries? The properties could be the names of device special files and the values the corresponding node phandles.
>>
>> I've been trying /really/ hard to avoid doing something like that
>> because a lot of the time the desired Linux dev name is a
>> implementation detail, and a potentially unstable one at that. If
>> Linux requires certain devices to have certain names because that is
>> how it hooks up clocks
>
> As I keep on saying, we don't _have_ to have to match on device name.
> If DT can come up with a better way to bind a clock to a particular
> device/connection name then DT can provide its own clk_get()
> implementation which does that.
Sorry, I overstated the situation. My point is only that I don't want
encode how Linux currently views the world into the DT, because
implementation details can and do change.
g.
^ permalink raw reply
* [PATCH RFC] igb: Fix false positive return of igb_get_auto_rd_done for 82580
From: Guenter Roeck @ 2011-06-21 19:02 UTC (permalink / raw)
To: Jeff Kirsher, Jesse Brandeburg, Bruce Allan, Carolyn Wyborny,
Don
Cc: e1000-devel, netdev, Tong Ho, Guenter Roeck
From: Tong Ho <tong.ho@ericsson.com>
82580 re-reads the port specific portion of eeprom after port reset.
If called immediately after a reset, igb_get_auto_rd_done() returns
false positive because the done bit has yet to transition from 1 to 0.
Add wrfl() immediately after resetting 82580 port or device,
plus a 1ms delay, to avoid the problem.
Signed-off-by: Tong Ho <tong.ho@ericsson.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
---
Sent as RFC since I am not entirely sure if the solution is the correct one
to address the problem we are seeing. If there is a better solution, please
let me know.
drivers/net/igb/e1000_82575.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index 0f563c8..28dae48 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -1735,10 +1735,10 @@ static s32 igb_reset_hw_82580(struct e1000_hw *hw)
ctrl |= E1000_CTRL_RST;
wr32(E1000_CTRL, ctrl);
+ wrfl();
/* Add delay to insure DEV_RST has time to complete */
- if (global_device_reset)
- msleep(5);
+ msleep(global_device_reset ? 5 : 1);
ret_val = igb_get_auto_rd_done(hw);
if (ret_val) {
--
1.7.3.1
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox