* Re: [patch net-next-2.6] net: make dev->master general
From: David Miller @ 2011-02-13 19:08 UTC (permalink / raw)
To: jpirko; +Cc: netdev, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian
In-Reply-To: <20110212164836.GB12156@psychotron.redhat.com>
From: Jiri Pirko <jpirko@redhat.com>
Date: Sat, 12 Feb 2011 17:48:36 +0100
> dev->master is now tightly connected to bonding driver. This patch makes
> this pointer more general and ready to be used by others.
>
> - netdev_set_master() - bond specifics moved to new function
> netdev_set_bond_master()
> - introduced netif_is_bond_slave() to check if device is a bonding slave
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Applied.
^ permalink raw reply
* Re: [PATCH] Don't potentially dereference NULL in net/dcb/dcbnl.c:dcbnl_getapp()
From: David Miller @ 2011-02-13 19:21 UTC (permalink / raw)
To: jj
Cc: linux-kernel, netdev, adobriyan, error27, shmulikr,
john.r.fastabend, lucy.liu
In-Reply-To: <alpine.LNX.2.00.1102102253230.8012@swampdragon.chaosbits.net>
From: Jesper Juhl <jj@chaosbits.net>
Date: Thu, 10 Feb 2011 22:57:16 +0100 (CET)
> nla_nest_start() may return NULL. If it does then we'll blow up in
> nla_nest_end() when we dereference the pointer.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Applied.
^ permalink raw reply
* Re: [PATCH] USB Network driver infrastructure: Fix leak when usb_autopm_get_interface() returns less than zero in kevent().
From: David Miller @ 2011-02-13 19:21 UTC (permalink / raw)
To: jj; +Cc: linux-kernel, linux-usb, netdev, gregkh, dbrownell, dhollis
In-Reply-To: <alpine.LNX.2.00.1102102152450.26035@swampdragon.chaosbits.net>
From: Jesper Juhl <jj@chaosbits.net>
Date: Thu, 10 Feb 2011 21:58:45 +0100 (CET)
> We'll leak the memory allocated to 'urb' in
> drivers/net/usb/usbnet.c:kevent() when we 'goto fail_lowmem' and the 'urb'
> variable goes out of scope while still completely unused.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Applied.
^ permalink raw reply
* [patch net-next-2.6 1/4] rtnetlink: implement setting of master device
From: Jiri Pirko @ 2011-02-13 19:31 UTC (permalink / raw)
To: netdev; +Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian
This patch allows userspace to enslave/release slave devices via netlink
interface using IFLA_MASTER. This introduces generic way to add/remove
underling devices.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
include/linux/netdevice.h | 12 ++++++++++++
net/core/rtnetlink.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 5a42b10..d08ef65 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -783,6 +783,14 @@ struct netdev_tc_txq {
* Set hardware filter for RFS. rxq_index is the target queue index;
* flow_id is a flow ID to be passed to rps_may_expire_flow() later.
* Return the filter ID on success, or a negative error code.
+ *
+ * Slave management functions (for bridge, bonding, etc). User should
+ * call netdev_set_master() to set dev->master properly.
+ * int (*ndo_add_slave)(struct net_device *dev, struct net_device *slave_dev);
+ * Called to make another netdev an underling.
+ *
+ * int (*ndo_del_slave)(struct net_device *dev, struct net_device *slave_dev);
+ * Called to release previously enslaved netdev.
*/
#define HAVE_NET_DEVICE_OPS
struct net_device_ops {
@@ -862,6 +870,10 @@ struct net_device_ops {
u16 rxq_index,
u32 flow_id);
#endif
+ int (*ndo_add_slave)(struct net_device *dev,
+ struct net_device *slave_dev);
+ int (*ndo_del_slave)(struct net_device *dev,
+ struct net_device *slave_dev);
};
/*
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index da0fe45..20d067a 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1036,6 +1036,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
[IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
[IFLA_MTU] = { .type = NLA_U32 },
[IFLA_LINK] = { .type = NLA_U32 },
+ [IFLA_MASTER] = { .type = NLA_U32 },
[IFLA_TXQLEN] = { .type = NLA_U32 },
[IFLA_WEIGHT] = { .type = NLA_U32 },
[IFLA_OPERSTATE] = { .type = NLA_U8 },
@@ -1178,6 +1179,41 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr *attr)
return err;
}
+static int do_set_master(struct net_device *dev, int ifindex)
+{
+ struct net_device *master_dev;
+ const struct net_device_ops *ops;
+ int err;
+
+ if (dev->master) {
+ if (dev->master->ifindex == ifindex)
+ return 0;
+ ops = dev->master->netdev_ops;
+ if (ops->ndo_del_slave) {
+ err = ops->ndo_del_slave(dev->master, dev);
+ if (err)
+ return err;
+ } else {
+ return -EOPNOTSUPP;
+ }
+ }
+
+ if (ifindex) {
+ master_dev = __dev_get_by_index(dev_net(dev), ifindex);
+ if (!master_dev)
+ return -EINVAL;
+ ops = master_dev->netdev_ops;
+ if (ops->ndo_add_slave) {
+ err = ops->ndo_add_slave(master_dev, dev);
+ if (err)
+ return err;
+ } else {
+ return -EOPNOTSUPP;
+ }
+ }
+ return 0;
+}
+
static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
struct nlattr **tb, char *ifname, int modified)
{
@@ -1301,6 +1337,12 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
goto errout;
}
+ if (tb[IFLA_MASTER]) {
+ err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
+ if (err)
+ goto errout;
+ }
+
if (tb[IFLA_TXQLEN])
dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
--
1.7.3.4
^ permalink raw reply related
* [patch iproute2 2/4] iplink: implement setting of master device
From: Jiri Pirko @ 2011-02-13 19:32 UTC (permalink / raw)
To: netdev; +Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian
In-Reply-To: <20110213193105.GD2740@psychotron.redhat.com>
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
ip/iplink.c | 16 ++++++++++++++++
man/man8/ip.8 | 15 ++++++++++++++-
2 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/ip/iplink.c b/ip/iplink.c
index cb2c4f5..7a1722c 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -71,6 +71,8 @@ void iplink_usage(void)
fprintf(stderr, " [ vf NUM [ mac LLADDR ]\n");
fprintf(stderr, " [ vlan VLANID [ qos VLAN-QOS ] ]\n");
fprintf(stderr, " [ rate TXRATE ] ] \n");
+ fprintf(stderr, " [ master DEVICE ]\n");
+ fprintf(stderr, " [ nomaster ]\n");
fprintf(stderr, " ip link show [ DEVICE ]\n");
if (iplink_have_newlink()) {
@@ -361,6 +363,20 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
if (len < 0)
return -1;
addattr_nest_end(&req->n, vflist);
+#ifdef IFLA_MASTER
+ } else if (matches(*argv, "master") == 0) {
+ int ifindex;
+ NEXT_ARG();
+ ifindex = ll_name_to_index(*argv);
+ if (!ifindex)
+ invarg("Device does not exist\n", *argv);
+ addattr_l(&req->n, sizeof(*req), IFLA_MASTER,
+ &ifindex, 4);
+ } else if (matches(*argv, "nomaster") == 0) {
+ int ifindex = 0;
+ addattr_l(&req->n, sizeof(*req), IFLA_MASTER,
+ &ifindex, 4);
+#endif
#ifdef IFF_DYNAMIC
} else if (matches(*argv, "dynamic") == 0) {
NEXT_ARG();
diff --git a/man/man8/ip.8 b/man/man8/ip.8
index 8d55fa9..a473868 100644
--- a/man/man8/ip.8
+++ b/man/man8/ip.8
@@ -95,7 +95,12 @@ ip \- show / manipulate routing, devices, policy routing and tunnels
.B qos
.IR VLAN-QOS " ] ] ["
.B rate
-.IR TXRATE " ]"
+.IR TXRATE " ] |"
+.br
+.B master
+.IR DEVICE
+.br
+.B nomaster
.ti -8
.B ip link show
@@ -1038,6 +1043,14 @@ Setting this parameter to 0 disables rate limiting. The
parameter must be specified.
.in -8
+.TP
+.BI master " DEVICE"
+set master device of the device (enslave device).
+
+.TP
+.BI nomaster
+unset master device of the device (release device).
+
.PP
.B Warning:
If multiple parameter changes are requested,
--
1.7.3.4
^ permalink raw reply related
* [patch net-next-2.6 3/4] bond: implement [add/del]_slave ops
From: Jiri Pirko @ 2011-02-13 19:33 UTC (permalink / raw)
To: netdev; +Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian
In-Reply-To: <20110213193105.GD2740@psychotron.redhat.com>
allow enslaving/releasing using netlink interface
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/bonding/bond_main.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 9f87787..77e3c6a 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4657,6 +4657,8 @@ static const struct net_device_ops bond_netdev_ops = {
.ndo_netpoll_cleanup = bond_netpoll_cleanup,
.ndo_poll_controller = bond_poll_controller,
#endif
+ .ndo_add_slave = bond_enslave,
+ .ndo_del_slave = bond_release,
};
static void bond_destructor(struct net_device *bond_dev)
--
1.7.3.4
^ permalink raw reply related
* [patch net-next-2.6 4/4] bridge: implement [add/del]_slave ops
From: Jiri Pirko @ 2011-02-13 19:33 UTC (permalink / raw)
To: netdev; +Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian
In-Reply-To: <20110213193105.GD2740@psychotron.redhat.com>
add possibility to addif/delif via rtnetlink
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
net/bridge/br_device.c | 17 +++++++++++++++++
net/bridge/br_if.c | 11 ++++++++++-
2 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 5564435..1461b19 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -297,6 +297,21 @@ void br_netpoll_disable(struct net_bridge_port *p)
#endif
+static int br_add_slave(struct net_device *dev, struct net_device *slave_dev)
+
+{
+ struct net_bridge *br = netdev_priv(dev);
+
+ return br_add_if(br, slave_dev);
+}
+
+static int br_del_slave(struct net_device *dev, struct net_device *slave_dev)
+{
+ struct net_bridge *br = netdev_priv(dev);
+
+ return br_del_if(br, slave_dev);
+}
+
static const struct ethtool_ops br_ethtool_ops = {
.get_drvinfo = br_getinfo,
.get_link = ethtool_op_get_link,
@@ -326,6 +341,8 @@ static const struct net_device_ops br_netdev_ops = {
.ndo_netpoll_cleanup = br_netpoll_cleanup,
.ndo_poll_controller = br_poll_controller,
#endif
+ .ndo_add_slave = br_add_slave,
+ .ndo_del_slave = br_del_slave,
};
static void br_dev_free(struct net_device *dev)
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 2a6801d..dce8f00 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -148,6 +148,8 @@ static void del_nbp(struct net_bridge_port *p)
netdev_rx_handler_unregister(dev);
+ netdev_set_master(dev, NULL);
+
br_multicast_del_port(p);
kobject_uevent(&p->kobj, KOBJ_REMOVE);
@@ -429,10 +431,14 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
if (br_netpoll_info(br) && ((err = br_netpoll_enable(p))))
goto err3;
- err = netdev_rx_handler_register(dev, br_handle_frame, p);
+ err = netdev_set_master(dev, br->dev);
if (err)
goto err3;
+ err = netdev_rx_handler_register(dev, br_handle_frame, p);
+ if (err)
+ goto err4;
+
dev->priv_flags |= IFF_BRIDGE_PORT;
dev_disable_lro(dev);
@@ -455,6 +461,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
kobject_uevent(&p->kobj, KOBJ_ADD);
return 0;
+
+err4:
+ netdev_set_master(dev, NULL);
err3:
sysfs_remove_link(br->ifobj, p->dev->name);
err2:
--
1.7.3.4
^ permalink raw reply related
* Re: [patch net-next-2.6 1/4] rtnetlink: implement setting of master device
From: Patrick McHardy @ 2011-02-13 19:43 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, davem, shemminger, fubar, eric.dumazet, nicolas.2p.debian
In-Reply-To: <20110213193105.GD2740@psychotron.redhat.com>
Am 13.02.2011 20:31, schrieb Jiri Pirko:
> This patch allows userspace to enslave/release slave devices via netlink
> interface using IFLA_MASTER. This introduces generic way to add/remove
> underling devices.
Looks good to me, just one question:
> @@ -1301,6 +1337,12 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
> goto errout;
> }
>
> + if (tb[IFLA_MASTER]) {
> + err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
> + if (err)
> + goto errout;
> + }
Any reason why you're not setting "modified" here?
> +
> if (tb[IFLA_TXQLEN])
> dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
>
^ permalink raw reply
* Re: [patch net-next-2.6 1/4] rtnetlink: implement setting of master device
From: Jiri Pirko @ 2011-02-13 20:15 UTC (permalink / raw)
To: Patrick McHardy
Cc: netdev, davem, shemminger, fubar, eric.dumazet, nicolas.2p.debian
In-Reply-To: <4D583467.6020803@trash.net>
Sun, Feb 13, 2011 at 08:43:35PM CET, kaber@trash.net wrote:
>Am 13.02.2011 20:31, schrieb Jiri Pirko:
>> This patch allows userspace to enslave/release slave devices via netlink
>> interface using IFLA_MASTER. This introduces generic way to add/remove
>> underling devices.
>
>Looks good to me, just one question:
>
>> @@ -1301,6 +1337,12 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
>> goto errout;
>> }
>>
>> + if (tb[IFLA_MASTER]) {
>> + err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
>> + if (err)
>> + goto errout;
>> + }
>
>Any reason why you're not setting "modified" here?
Ugh, forgot that, thanks. Here's repost:
Subject: [patch net-next-2.6 1/4] rtnetlink: implement setting of master device
This patch allows userspace to enslave/release slave devices via netlink
interface using IFLA_MASTER. This introduces generic way to add/remove
underling devices.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
include/linux/netdevice.h | 12 ++++++++++++
net/core/rtnetlink.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 5a42b10..d08ef65 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -783,6 +783,14 @@ struct netdev_tc_txq {
* Set hardware filter for RFS. rxq_index is the target queue index;
* flow_id is a flow ID to be passed to rps_may_expire_flow() later.
* Return the filter ID on success, or a negative error code.
+ *
+ * Slave management functions (for bridge, bonding, etc). User should
+ * call netdev_set_master() to set dev->master properly.
+ * int (*ndo_add_slave)(struct net_device *dev, struct net_device *slave_dev);
+ * Called to make another netdev an underling.
+ *
+ * int (*ndo_del_slave)(struct net_device *dev, struct net_device *slave_dev);
+ * Called to release previously enslaved netdev.
*/
#define HAVE_NET_DEVICE_OPS
struct net_device_ops {
@@ -862,6 +870,10 @@ struct net_device_ops {
u16 rxq_index,
u32 flow_id);
#endif
+ int (*ndo_add_slave)(struct net_device *dev,
+ struct net_device *slave_dev);
+ int (*ndo_del_slave)(struct net_device *dev,
+ struct net_device *slave_dev);
};
/*
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index da0fe45..49f7ea5 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1036,6 +1036,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
[IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
[IFLA_MTU] = { .type = NLA_U32 },
[IFLA_LINK] = { .type = NLA_U32 },
+ [IFLA_MASTER] = { .type = NLA_U32 },
[IFLA_TXQLEN] = { .type = NLA_U32 },
[IFLA_WEIGHT] = { .type = NLA_U32 },
[IFLA_OPERSTATE] = { .type = NLA_U8 },
@@ -1178,6 +1179,41 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr *attr)
return err;
}
+static int do_set_master(struct net_device *dev, int ifindex)
+{
+ struct net_device *master_dev;
+ const struct net_device_ops *ops;
+ int err;
+
+ if (dev->master) {
+ if (dev->master->ifindex == ifindex)
+ return 0;
+ ops = dev->master->netdev_ops;
+ if (ops->ndo_del_slave) {
+ err = ops->ndo_del_slave(dev->master, dev);
+ if (err)
+ return err;
+ } else {
+ return -EOPNOTSUPP;
+ }
+ }
+
+ if (ifindex) {
+ master_dev = __dev_get_by_index(dev_net(dev), ifindex);
+ if (!master_dev)
+ return -EINVAL;
+ ops = master_dev->netdev_ops;
+ if (ops->ndo_add_slave) {
+ err = ops->ndo_add_slave(master_dev, dev);
+ if (err)
+ return err;
+ } else {
+ return -EOPNOTSUPP;
+ }
+ }
+ return 0;
+}
+
static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
struct nlattr **tb, char *ifname, int modified)
{
@@ -1301,6 +1337,13 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
goto errout;
}
+ if (tb[IFLA_MASTER]) {
+ err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
+ if (err)
+ goto errout;
+ modified = 1;
+ }
+
if (tb[IFLA_TXQLEN])
dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
--
1.7.3.4
^ permalink raw reply related
* Re: [patch net-next-2.6 1/4] rtnetlink: implement setting of master device
From: Patrick McHardy @ 2011-02-13 20:16 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, davem, shemminger, fubar, eric.dumazet, nicolas.2p.debian
In-Reply-To: <20110213201536.GH2740@psychotron.redhat.com>
Am 13.02.2011 21:15, schrieb Jiri Pirko:
> Subject: [patch net-next-2.6 1/4] rtnetlink: implement setting of master device
>
> This patch allows userspace to enslave/release slave devices via netlink
> interface using IFLA_MASTER. This introduces generic way to add/remove
> underling devices.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Acked-by: Patrick McHardy <kaber@trash.net>
^ permalink raw reply
* Re: Mass udp flow reboot linux with RealTek RTL-8169 Gigabit
From: Francois Romieu @ 2011-02-13 20:34 UTC (permalink / raw)
To: Seblu; +Cc: Eric Dumazet, lkml, netdev, Ivan Vecera
In-Reply-To: <AANLkTikLOJ-XcwfdbWS19DKzh2s91tn5pQjJe0+CeAN-@mail.gmail.com>
Seblu <seblu@seblu.net> :
[...]
> > NIC seems to be reset frequently but host stop rebooting. \o//
> ok after about 1 hour of iperf, host reboot.
Can you apply the patch below on top of 2.6.38-rc4 ?
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 59ccf0c..5d64b80 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -4645,6 +4645,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
switch (tp->mac_version) {
/* Work around for rx fifo overflow */
case RTL_GIGA_MAC_VER_11:
+ case RTL_GIGA_MAC_VER_20:
case RTL_GIGA_MAC_VER_22:
case RTL_GIGA_MAC_VER_26:
netif_stop_queue(dev);
@@ -4653,7 +4654,6 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
/* Testers needed. */
case RTL_GIGA_MAC_VER_17:
case RTL_GIGA_MAC_VER_19:
- case RTL_GIGA_MAC_VER_20:
case RTL_GIGA_MAC_VER_21:
case RTL_GIGA_MAC_VER_23:
case RTL_GIGA_MAC_VER_24:
^ permalink raw reply related
* [PATCH] ATM, Solos PCI ADSL2+: Don't deref NULL pointer if net_ratelimit() and alloc_skb() interact badly.
From: Jesper Juhl @ 2011-02-13 20:49 UTC (permalink / raw)
To: linux-kernel
Cc: Chas Williams, linux-atm-general, netdev, Nathan Williams,
David Woodhouse, Treker Chen
If alloc_skb() fails to allocate memory and returns NULL then we want to
return -ENOMEM from drivers/atm/solos-pci.c::popen() regardless of the
value of net_ratelimit(). The way the code is today, we may not return if
net_ratelimit() returns 0, then we'll proceed to pass a NULL pointer to
skb_put() which will blow up in our face.
This patch ensures that we always return -ENOMEM on alloc_skb() failure
and only let the dev_warn() be controlled by the value of net_ratelimit().
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
solos-pci.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 73fb1c4..25ef1a4 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -866,8 +866,9 @@ static int popen(struct atm_vcc *vcc)
}
skb = alloc_skb(sizeof(*header), GFP_ATOMIC);
- if (!skb && net_ratelimit()) {
- dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n");
+ if (!skb) {
+ if (net_ratelimit())
+ dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n");
return -ENOMEM;
}
header = (void *)skb_put(skb, sizeof(*header));
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
^ permalink raw reply related
* Re: [PATCH 02/14] net/fec: release mem_region requested in probe in error path and remove
From: Uwe Kleine-König @ 2011-02-13 21:07 UTC (permalink / raw)
To: David Miller; +Cc: netdev, shawn.guo, kernel
In-Reply-To: <20110211.212532.229740768.davem@davemloft.net>
Hi David,
On Fri, Feb 11, 2011 at 09:25:32PM -0800, David Miller wrote:
> I can't pull from that tree because it is _NOT_ based upon net-next-2.6
> and therefore brings in all kinds of commits not related to your work.
Sorry, I'm not used to the customs on netdev. I can rebase, but still I
wonder about the reason you cannot pull for. The only reason I can
imagine is that you fear unrelated breakage when taking these patches
that are already in Linus' tree. But if it's that, wouldn't it be great
the realize this breakage already now and not only during the next merge
window?
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply
* Re: [PATCH 02/14] net/fec: release mem_region requested in probe in error path and remove
From: David Miller @ 2011-02-13 21:15 UTC (permalink / raw)
To: u.kleine-koenig; +Cc: netdev, shawn.guo, kernel
In-Reply-To: <20110213210709.GA13279@pengutronix.de>
From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date: Sun, 13 Feb 2011 22:07:09 +0100
> Hi David,
>
> On Fri, Feb 11, 2011 at 09:25:32PM -0800, David Miller wrote:
>> I can't pull from that tree because it is _NOT_ based upon net-next-2.6
>> and therefore brings in all kinds of commits not related to your work.
> Sorry, I'm not used to the customs on netdev. I can rebase, but still I
> wonder about the reason you cannot pull for. The only reason I can
> imagine is that you fear unrelated breakage when taking these patches
> that are already in Linus' tree. But if it's that, wouldn't it be great
> the realize this breakage already now and not only during the next merge
> window?
My trees only merge in Linus's tree when absolutely necessary,
to resolve conflicts or similar.
We don't bring in unrelated changes into my tree, just for the
sake of doing so.
Otherwise Linus gets all of these ugly merge commits when he
pulls from me, which are entirely unnecessary.
^ permalink raw reply
* [PATCH] Net, USB, Option, hso: Do not dereference NULL pointer
From: Jesper Juhl @ 2011-02-13 21:15 UTC (permalink / raw)
To: linux-kernel
Cc: linux-usb, netdev, Greg Kroah-Hartman, Jan Dumon, Filip Aben,
Denis Joseph Barrow, Andrew Bird
In drivers/net/usb/hso.c::hso_create_bulk_serial_device() we have this
code:
...
serial = kzalloc(sizeof(*serial), GFP_KERNEL);
if (!serial)
goto exit;
...
exit:
hso_free_tiomget(serial);
...
hso_free_tiomget() directly dereferences its argument, which in the
example above is a NULL pointer, ouch.
I could just add a 'if (serial)' test at the 'exit' label, but since most
freeing functions in the kernel accept NULL pointers (and it seems like
this was also assumed here) I opted to instead change 'hso_free_tiomget()'
so that it is safe to call it with a NULL argument. I also modified the
function to get rid of a pointles conditional before the call to
'usb_free_urb()' since that function already tests for NULL itself -
besides fixing the NULL deref this change also buys us a few bytes in
size.
Before:
$ size drivers/net/usb/hso.o
text data bss dec hex filename
32200 592 9960 42752 a700 drivers/net/usb/hso.o
After:
$ size drivers/net/usb/hso.o
text data bss dec hex filename
32196 592 9960 42748 a6fc drivers/net/usb/hso.o
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
hso.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index bed8fce..6d83812 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2628,15 +2628,15 @@ exit:
static void hso_free_tiomget(struct hso_serial *serial)
{
- struct hso_tiocmget *tiocmget = serial->tiocmget;
+ struct hso_tiocmget *tiocmget;
+ if (!serial)
+ return;
+ tiocmget = serial->tiocmget;
if (tiocmget) {
- if (tiocmget->urb) {
- usb_free_urb(tiocmget->urb);
- tiocmget->urb = NULL;
- }
+ usb_free_urb(tiocmget->urb);
+ tiocmget->urb = NULL;
serial->tiocmget = NULL;
kfree(tiocmget);
-
}
}
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
^ permalink raw reply related
* Re: potential null pointer dereference in drivers/isdn/hisax/isdnl2.c
From: David Miller @ 2011-02-14 0:53 UTC (permalink / raw)
To: jj; +Cc: linux-kernel, netdev, tj, isdn
In-Reply-To: <alpine.LNX.2.00.1102032121180.15101@swampdragon.chaosbits.net>
From: Jesper Juhl <jj@chaosbits.net>
Date: Thu, 3 Feb 2011 21:27:56 +0100 (CET)
> In drivers/isdn/hisax/isdnl2.c:l2_pull_iqueue() we have this:
>
> ...
> skb = alloc_skb(oskb->len + i, GFP_ATOMIC);
> memcpy(skb_put(skb, i), header, i);
> ...
>
> If alloc_skb() fails and returns NULL then the second line will cause a
> NULL pointer dereference - skb_put() gives the pointer to
> skb_tail_pointer() which dereferences it.
>
> I'm not quite sure how this should be dealt with, so I'll just report it
> rather than submit a patch. Happy bug fixing :-)
Thanks Jesper, I'll fix this like so:
--------------------
hisax: Fix unchecked alloc_skb() return.
Jesper Juhl noticed that l2_pull_iqueue() does not
check to see if alloc_skb() fails.
Fix this by first trying to reallocate the headroom
if necessary, rather than later after we've made hard
to undo state changes.
Reported-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/isdn/hisax/isdnl2.c | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/drivers/isdn/hisax/isdnl2.c b/drivers/isdn/hisax/isdnl2.c
index 0858791..98ac835 100644
--- a/drivers/isdn/hisax/isdnl2.c
+++ b/drivers/isdn/hisax/isdnl2.c
@@ -1243,14 +1243,21 @@ l2_st7_tout_203(struct FsmInst *fi, int event, void *arg)
st->l2.rc = 0;
}
+static int l2_hdr_space_needed(struct Layer2 *l2)
+{
+ int len = test_bit(FLG_LAPD, &l2->flag) ? 2 : 1;
+
+ return len + (test_bit(FLG_LAPD, &l2->flag) ? 2 : 1);
+}
+
static void
l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct sk_buff *skb, *oskb;
+ struct sk_buff *skb;
struct Layer2 *l2 = &st->l2;
u_char header[MAX_HEADER_LEN];
- int i;
+ int i, hdr_space_needed;
int unsigned p1;
u_long flags;
@@ -1261,6 +1268,16 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
if (!skb)
return;
+ hdr_space_needed = l2_hdr_space_needed(l2);
+ if (hdr_space_needed > skb_headroom(skb)) {
+ struct sk_buff *orig_skb = skb;
+
+ skb = skb_realloc_headroom(skb, hdr_space_needed);
+ if (!skb) {
+ dev_kfree_skb(orig_skb);
+ return;
+ }
+ }
spin_lock_irqsave(&l2->lock, flags);
if(test_bit(FLG_MOD128, &l2->flag))
p1 = (l2->vs - l2->va) % 128;
@@ -1285,19 +1302,7 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
l2->vs = (l2->vs + 1) % 8;
}
spin_unlock_irqrestore(&l2->lock, flags);
- p1 = skb->data - skb->head;
- if (p1 >= i)
- memcpy(skb_push(skb, i), header, i);
- else {
- printk(KERN_WARNING
- "isdl2 pull_iqueue skb header(%d/%d) too short\n", i, p1);
- oskb = skb;
- skb = alloc_skb(oskb->len + i, GFP_ATOMIC);
- memcpy(skb_put(skb, i), header, i);
- skb_copy_from_linear_data(oskb,
- skb_put(skb, oskb->len), oskb->len);
- dev_kfree_skb(oskb);
- }
+ memcpy(skb_push(skb, i), header, i);
st->l2.l2l1(st, PH_PULL | INDICATION, skb);
test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag);
if (!test_and_set_bit(FLG_T200_RUN, &st->l2.flag)) {
--
1.7.4.1
^ permalink raw reply related
* Re: [PATCH] ATM, Solos PCI ADSL2+: Don't deref NULL pointer if net_ratelimit() and alloc_skb() interact badly.
From: David Miller @ 2011-02-14 0:55 UTC (permalink / raw)
To: jj; +Cc: linux-kernel, chas, linux-atm-general, netdev, nathan, dwmw2,
treker
In-Reply-To: <alpine.LNX.2.00.1102132142460.18930@swampdragon.chaosbits.net>
From: Jesper Juhl <jj@chaosbits.net>
Date: Sun, 13 Feb 2011 21:49:32 +0100 (CET)
> If alloc_skb() fails to allocate memory and returns NULL then we want to
> return -ENOMEM from drivers/atm/solos-pci.c::popen() regardless of the
> value of net_ratelimit(). The way the code is today, we may not return if
> net_ratelimit() returns 0, then we'll proceed to pass a NULL pointer to
> skb_put() which will blow up in our face.
> This patch ensures that we always return -ENOMEM on alloc_skb() failure
> and only let the dev_warn() be controlled by the value of net_ratelimit().
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Applied.
^ permalink raw reply
* Re: [PATCH] Net, USB, Option, hso: Do not dereference NULL pointer
From: David Miller @ 2011-02-14 0:56 UTC (permalink / raw)
To: jj; +Cc: linux-kernel, linux-usb, netdev, gregkh, j.dumon, f.aben, d.barow,
ajb
In-Reply-To: <alpine.LNX.2.00.1102132206390.18930@swampdragon.chaosbits.net>
From: Jesper Juhl <jj@chaosbits.net>
Date: Sun, 13 Feb 2011 22:15:35 +0100 (CET)
> In drivers/net/usb/hso.c::hso_create_bulk_serial_device() we have this
> code:
> ...
> serial = kzalloc(sizeof(*serial), GFP_KERNEL);
> if (!serial)
> goto exit;
> ...
> exit:
> hso_free_tiomget(serial);
> ...
> hso_free_tiomget() directly dereferences its argument, which in the
> example above is a NULL pointer, ouch.
> I could just add a 'if (serial)' test at the 'exit' label, but since most
> freeing functions in the kernel accept NULL pointers (and it seems like
> this was also assumed here) I opted to instead change 'hso_free_tiomget()'
> so that it is safe to call it with a NULL argument. I also modified the
> function to get rid of a pointles conditional before the call to
> 'usb_free_urb()' since that function already tests for NULL itself -
> besides fixing the NULL deref this change also buys us a few bytes in
> size.
> Before:
> $ size drivers/net/usb/hso.o
> text data bss dec hex filename
> 32200 592 9960 42752 a700 drivers/net/usb/hso.o
> After:
> $ size drivers/net/usb/hso.o
> text data bss dec hex filename
> 32196 592 9960 42748 a6fc drivers/net/usb/hso.o
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Applied.
^ permalink raw reply
* Re: [patch net-next-2.6 1/4] rtnetlink: implement setting of master device
From: David Miller @ 2011-02-14 0:58 UTC (permalink / raw)
To: kaber; +Cc: jpirko, netdev, shemminger, fubar, eric.dumazet,
nicolas.2p.debian
In-Reply-To: <4D583C2F.7070308@trash.net>
From: Patrick McHardy <kaber@trash.net>
Date: Sun, 13 Feb 2011 21:16:47 +0100
> Am 13.02.2011 21:15, schrieb Jiri Pirko:
>> Subject: [patch net-next-2.6 1/4] rtnetlink: implement setting of master device
>>
>> This patch allows userspace to enslave/release slave devices via netlink
>> interface using IFLA_MASTER. This introduces generic way to add/remove
>> underling devices.
>>
>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>
> Acked-by: Patrick McHardy <kaber@trash.net>
Applied.
^ permalink raw reply
* Re: [patch net-next-2.6 3/4] bond: implement [add/del]_slave ops
From: David Miller @ 2011-02-14 0:58 UTC (permalink / raw)
To: jpirko; +Cc: netdev, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian
In-Reply-To: <20110213193300.GF2740@psychotron.redhat.com>
From: Jiri Pirko <jpirko@redhat.com>
Date: Sun, 13 Feb 2011 20:33:01 +0100
> allow enslaving/releasing using netlink interface
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Applied.
^ permalink raw reply
* Re: [patch net-next-2.6 4/4] bridge: implement [add/del]_slave ops
From: David Miller @ 2011-02-14 0:59 UTC (permalink / raw)
To: jpirko; +Cc: netdev, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian
In-Reply-To: <20110213193341.GG2740@psychotron.redhat.com>
From: Jiri Pirko <jpirko@redhat.com>
Date: Sun, 13 Feb 2011 20:33:42 +0100
> add possibility to addif/delif via rtnetlink
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Applied.
^ permalink raw reply
* Re: [PATCH] stmmac: enable wol via magic frame by default.
From: David Miller @ 2011-02-14 1:00 UTC (permalink / raw)
To: peppe.cavallaro; +Cc: netdev
In-Reply-To: <1297414306-11271-1-git-send-email-peppe.cavallaro@st.com>
From: Peppe CAVALLARO <peppe.cavallaro@st.com>
Date: Fri, 11 Feb 2011 09:51:46 +0100
> This patch enables it by default when the driver starts.
> This has been required by many people and seems to actually be
> useful on STB.
> At any rate, the WoL modes can be selected and turned-on/off
> by using the ethtool at run-time by users.
>
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Applied.
^ permalink raw reply
* RE: [PATCH net-next-2.6 v7 1/1] can: c_can: Added support for Bosch C_CAN controller
From: Bhupesh SHARMA @ 2011-02-14 3:54 UTC (permalink / raw)
To: David Miller, mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Cc: Socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <20110213.110530.98884040.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Hi David,
> -----Original Message-----
> From: David Miller [mailto:davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org]
> Sent: Monday, February 14, 2011 12:36 AM
> To: mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
> Cc: Bhupesh SHARMA; netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Socketcan-
> core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
> Subject: Re: [PATCH net-next-2.6 v7 1/1] can: c_can: Added support for
> Bosch C_CAN controller
>
> From: David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
> Date: Sun, 13 Feb 2011 10:52:16 -0800 (PST)
>
> > From: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > Date: Sat, 12 Feb 2011 18:18:37 +0100
> >
> >> On 02/11/2011 11:17 AM, Bhupesh Sharma wrote:
> >>> Bosch C_CAN controller is a full-CAN implementation which is
> compliant
> >>> to CAN protocol version 2.0 part A and B. Bosch C_CAN user manual
> can be
> >>> obtained from:
> >>> http://www.semiconductors.bosch.de/media/en/pdf/ipmodules_1/
> >>> c_can/users_manual_c_can.pdf
> >>>
> >>> This patch adds the support for this controller.
> >>> The following are the design choices made while writing the
> controller
> >>> driver:
> >>> 1. Interface Register set IF1 has be used only in the current
> design.
> >>> 2. Out of the 32 Message objects available, 16 are kept aside for
> RX
> >>> purposes and the rest for TX purposes.
> >>> 3. NAPI implementation is such that both the TX and RX paths
> function
> >>> in polling mode.
> >>>
> >>> Signed-off-by: Bhupesh Sharma <bhupesh.sharma-qxv4g6HH51o@public.gmane.org>
> >>
> >> Good work!
> >>
> >> Acked-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> >
> > Applied.
>
> Actually, I'm reverting because this causes build regressions:
>
> ERROR: "clk_get_rate" [drivers/net/can/c_can/c_can_platform.ko]
> undefined!
> ERROR: "clk_get" [drivers/net/can/c_can/c_can_platform.ko] undefined!
> ERROR: "clk_put" [drivers/net/can/c_can/c_can_platform.ko] undefined!
Oops.. I will send a v8 to correct this compilation issue a.s.a.p.
Regards,
Bhupesh
^ permalink raw reply
* [PATCH net-next-2.6 1/9] jme: Extract main and sub chip revision
From: Guo-Fu Tseng @ 2011-02-14 4:27 UTC (permalink / raw)
To: David Miller
Cc: Guo-Fu Tseng, linux-netdev, Aries Lee, Devinchiu, Ethan Hsiao
From: Guo-Fu Tseng <cooldavid@cooldavid.org>
Get the main and sub chip revision for later workaround use.
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
---
drivers/net/jme.c | 8 +++++---
drivers/net/jme.h | 8 +++++---
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index e97ebef..d44716e 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -2731,6 +2731,8 @@ jme_check_hw_ver(struct jme_adapter *jme)
jme->fpgaver = (chipmode & CM_FPGAVER_MASK) >> CM_FPGAVER_SHIFT;
jme->chiprev = (chipmode & CM_CHIPREV_MASK) >> CM_CHIPREV_SHIFT;
+ jme->chip_main_rev = jme->chiprev & 0xF;
+ jme->chip_sub_rev = (jme->chiprev >> 4) & 0xF;
}
static const struct net_device_ops jme_netdev_ops = {
@@ -2937,7 +2939,7 @@ jme_init_one(struct pci_dev *pdev,
jme_clear_pm(jme);
jme_set_phyfifoa(jme);
- pci_read_config_byte(pdev, PCI_REVISION_ID, &jme->rev);
+ pci_read_config_byte(pdev, PCI_REVISION_ID, &jme->pcirev);
if (!jme->fpgaver)
jme_phy_init(jme);
jme_phy_off(jme);
@@ -2964,14 +2966,14 @@ jme_init_one(struct pci_dev *pdev,
goto err_out_unmap;
}
- netif_info(jme, probe, jme->dev, "%s%s ver:%x rev:%x macaddr:%pM\n",
+ netif_info(jme, probe, jme->dev, "%s%s chiprev:%x pcirev:%x macaddr:%pM\n",
(jme->pdev->device == PCI_DEVICE_ID_JMICRON_JMC250) ?
"JMC250 Gigabit Ethernet" :
(jme->pdev->device == PCI_DEVICE_ID_JMICRON_JMC260) ?
"JMC260 Fast Ethernet" : "Unknown",
(jme->fpgaver != 0) ? " (FPGA)" : "",
(jme->fpgaver != 0) ? jme->fpgaver : jme->chiprev,
- jme->rev, netdev->dev_addr);
+ jme->pcirev, netdev->dev_addr);
return 0;
diff --git a/drivers/net/jme.h b/drivers/net/jme.h
index eac0926..32b2a9d 100644
--- a/drivers/net/jme.h
+++ b/drivers/net/jme.h
@@ -411,8 +411,10 @@ struct jme_adapter {
u32 rx_ring_mask;
u8 mrrs;
unsigned int fpgaver;
- unsigned int chiprev;
- u8 rev;
+ u8 chiprev;
+ u8 chip_main_rev;
+ u8 chip_sub_rev;
+ u8 pcirev;
u32 msg_enable;
struct ethtool_cmd old_ecmd;
unsigned int old_mtu;
@@ -1184,7 +1186,7 @@ enum jme_phy_reg17_vals {
/*
* Workaround
*/
-static inline int is_buggy250(unsigned short device, unsigned int chiprev)
+static inline int is_buggy250(unsigned short device, u8 chiprev)
{
return device == PCI_DEVICE_ID_JMICRON_JMC250 && chiprev == 0x11;
}
--
1.7.2.2
^ permalink raw reply related
* [PATCH net-next-2.6 2/9] jme: PHY Power control for new chip
From: Guo-Fu Tseng @ 2011-02-14 4:27 UTC (permalink / raw)
To: David Miller
Cc: Guo-Fu Tseng, linux-netdev, Aries Lee, Devinchiu, Ethan Hsiao
In-Reply-To: <1297657662-30289-1-git-send-email-cooldavid@cooldavid.org>
From: Guo-Fu Tseng <cooldavid@cooldavid.org>
After main chip rev 5, the hardware support more power saving
control registers.
Some Non-Linux drivers might turn off the phy power with new
interfaces, this patch makes it possible for Linux to turn it
on again.
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
---
drivers/net/jme.c | 68 ++++++++++++++++++++++++++++++++++++++++++-----------
drivers/net/jme.h | 52 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 106 insertions(+), 14 deletions(-)
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index d44716e..d446fdb 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -1577,6 +1577,38 @@ jme_free_irq(struct jme_adapter *jme)
}
static inline void
+jme_new_phy_on(struct jme_adapter *jme)
+{
+ u32 reg;
+
+ reg = jread32(jme, JME_PHY_PWR);
+ reg &= ~(PHY_PWR_DWN1SEL | PHY_PWR_DWN1SW |
+ PHY_PWR_DWN2 | PHY_PWR_CLKSEL);
+ jwrite32(jme, JME_PHY_PWR, reg);
+
+ pci_read_config_dword(jme->pdev, PCI_PRIV_PE1, ®);
+ reg &= ~PE1_GPREG0_PBG;
+ reg |= PE1_GPREG0_ENBG;
+ pci_write_config_dword(jme->pdev, PCI_PRIV_PE1, reg);
+}
+
+static inline void
+jme_new_phy_off(struct jme_adapter *jme)
+{
+ u32 reg;
+
+ reg = jread32(jme, JME_PHY_PWR);
+ reg |= PHY_PWR_DWN1SEL | PHY_PWR_DWN1SW |
+ PHY_PWR_DWN2 | PHY_PWR_CLKSEL;
+ jwrite32(jme, JME_PHY_PWR, reg);
+
+ pci_read_config_dword(jme->pdev, PCI_PRIV_PE1, ®);
+ reg &= ~PE1_GPREG0_PBG;
+ reg |= PE1_GPREG0_PDD3COLD;
+ pci_write_config_dword(jme->pdev, PCI_PRIV_PE1, reg);
+}
+
+static inline void
jme_phy_on(struct jme_adapter *jme)
{
u32 bmcr;
@@ -1584,6 +1616,22 @@ jme_phy_on(struct jme_adapter *jme)
bmcr = jme_mdio_read(jme->dev, jme->mii_if.phy_id, MII_BMCR);
bmcr &= ~BMCR_PDOWN;
jme_mdio_write(jme->dev, jme->mii_if.phy_id, MII_BMCR, bmcr);
+
+ if (new_phy_power_ctrl(jme->chip_main_rev))
+ jme_new_phy_on(jme);
+}
+
+static inline void
+jme_phy_off(struct jme_adapter *jme)
+{
+ u32 bmcr;
+
+ bmcr = jme_mdio_read(jme->dev, jme->mii_if.phy_id, MII_BMCR);
+ bmcr |= BMCR_PDOWN;
+ jme_mdio_write(jme->dev, jme->mii_if.phy_id, MII_BMCR, bmcr);
+
+ if (new_phy_power_ctrl(jme->chip_main_rev))
+ jme_new_phy_off(jme);
}
static int
@@ -1606,12 +1654,11 @@ jme_open(struct net_device *netdev)
jme_start_irq(jme);
- if (test_bit(JME_FLAG_SSET, &jme->flags)) {
- jme_phy_on(jme);
+ jme_phy_on(jme);
+ if (test_bit(JME_FLAG_SSET, &jme->flags))
jme_set_settings(netdev, &jme->old_ecmd);
- } else {
+ else
jme_reset_phy_processor(jme);
- }
jme_reset_link(jme);
@@ -1657,12 +1704,6 @@ jme_wait_link(struct jme_adapter *jme)
}
}
-static inline void
-jme_phy_off(struct jme_adapter *jme)
-{
- jme_mdio_write(jme->dev, jme->mii_if.phy_id, MII_BMCR, BMCR_PDOWN);
-}
-
static void
jme_powersave_phy(struct jme_adapter *jme)
{
@@ -3068,12 +3109,11 @@ jme_resume(struct pci_dev *pdev)
jme_clear_pm(jme);
pci_restore_state(pdev);
- if (test_bit(JME_FLAG_SSET, &jme->flags)) {
- jme_phy_on(jme);
+ jme_phy_on(jme);
+ if (test_bit(JME_FLAG_SSET, &jme->flags))
jme_set_settings(netdev, &jme->old_ecmd);
- } else {
+ else
jme_reset_phy_processor(jme);
- }
jme_start_irq(jme);
netif_device_attach(netdev);
diff --git a/drivers/net/jme.h b/drivers/net/jme.h
index 32b2a9d..c3764fc 100644
--- a/drivers/net/jme.h
+++ b/drivers/net/jme.h
@@ -103,6 +103,37 @@ enum jme_spi_op_bits {
#define HALF_US 500 /* 500 ns */
#define JMESPIIOCTL SIOCDEVPRIVATE
+#define PCI_PRIV_PE1 0xE4
+
+enum pci_priv_pe1_bit_masks {
+ PE1_ASPMSUPRT = 0x00000003, /*
+ * RW:
+ * Aspm_support[1:0]
+ * (R/W Port of 5C[11:10])
+ */
+ PE1_MULTIFUN = 0x00000004, /* RW: Multi_fun_bit */
+ PE1_RDYDMA = 0x00000008, /* RO: ~link.rdy_for_dma */
+ PE1_ASPMOPTL = 0x00000030, /* RW: link.rx10s_option[1:0] */
+ PE1_ASPMOPTH = 0x000000C0, /* RW: 10_req=[3]?HW:[2] */
+ PE1_GPREG0 = 0x0000FF00, /*
+ * SRW:
+ * Cfg_gp_reg0
+ * [7:6] phy_giga BG control
+ * [5] CREQ_N as CREQ_N1 (CPPE# as CREQ#)
+ * [4:0] Reserved
+ */
+ PE1_GPREG0_PBG = 0x0000C000, /* phy_giga BG control */
+ PE1_GPREG1 = 0x00FF0000, /* RW: Cfg_gp_reg1 */
+ PE1_REVID = 0xFF000000, /* RO: Rev ID */
+};
+
+enum pci_priv_pe1_values {
+ PE1_GPREG0_ENBG = 0x00000000, /* en BG */
+ PE1_GPREG0_PDD3COLD = 0x00004000, /* giga_PD + d3cold */
+ PE1_GPREG0_PDPCIESD = 0x00008000, /* giga_PD + pcie_shutdown */
+ PE1_GPREG0_PDPCIEIDDQ = 0x0000C000, /* giga_PD + pcie_iddq */
+};
+
/*
* Dynamic(adaptive)/Static PCC values
*/
@@ -499,6 +530,7 @@ enum jme_iomap_regs {
JME_PMCS = JME_MAC | 0x60, /* Power Management Control/Stat */
+ JME_PHY_PWR = JME_PHY | 0x24, /* New PHY Power Ctrl Register */
JME_PHY_CS = JME_PHY | 0x28, /* PHY Ctrl and Status Register */
JME_PHY_LINK = JME_PHY | 0x30, /* PHY Link Status Register */
JME_SMBCSR = JME_PHY | 0x40, /* SMB Control and Status */
@@ -835,6 +867,21 @@ enum jme_pmcs_bit_masks {
};
/*
+ * New PHY Power Control Register
+ */
+enum jme_phy_pwr_bit_masks {
+ PHY_PWR_DWN1SEL = 0x01000000, /* Phy_giga.p_PWR_DOWN1_SEL */
+ PHY_PWR_DWN1SW = 0x02000000, /* Phy_giga.p_PWR_DOWN1_SW */
+ PHY_PWR_DWN2 = 0x04000000, /* Phy_giga.p_PWR_DOWN2 */
+ PHY_PWR_CLKSEL = 0x08000000, /*
+ * XTL_OUT Clock select
+ * (an internal free-running clock)
+ * 0: xtl_out = phy_giga.A_XTL25_O
+ * 1: xtl_out = phy_giga.PD_OSC
+ */
+};
+
+/*
* Giga PHY Status Registers
*/
enum jme_phy_link_bit_mask {
@@ -1191,6 +1238,11 @@ static inline int is_buggy250(unsigned short device, u8 chiprev)
return device == PCI_DEVICE_ID_JMICRON_JMC250 && chiprev == 0x11;
}
+static inline int new_phy_power_ctrl(u8 chip_main_rev)
+{
+ return chip_main_rev >= 5;
+}
+
/*
* Function prototypes
*/
--
1.7.2.2
^ 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