* [PATCH 1/4] bna: Staticize local functions
From: Jingoo Han @ 2013-08-05 9:00 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, 'Rasesh Mody', Jingoo Han
bna_rx_sm_stop_wait_entry(), bna_rx_sm_rxf_stop_wait_entry(),
bna_rx_sm_started_entry(), bna_rx_sm_cleanup_wait_entry(),
and bna_rx_sm_cleanup_wait() are used only in this file.
Fix the following sparse warnings:
drivers/net/ethernet/brocade/bna/bna_tx_rx.c:1423:1: warning: symbol 'bna_rx_sm_stop_wait_entry' was not declared. Should it be
static?
drivers/net/ethernet/brocade/bna/bna_tx_rx.c:1476:1: warning: symbol 'bna_rx_sm_rxf_stop_wait_entry' was not declared. Should it be
static?
drivers/net/ethernet/brocade/bna/bna_tx_rx.c:1532:1: warning: symbol 'bna_rx_sm_started_entry' was not declared. Should it be
static?
drivers/net/ethernet/brocade/bna/bna_tx_rx.c:1597:1: warning: symbol 'bna_rx_sm_cleanup_wait_entry' was not declared. Should it be
static?
drivers/net/ethernet/brocade/bna/bna_tx_rx.c:1602:1: warning: symbol 'bna_rx_sm_cleanup_wait' was not declared. Should it be static?
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/net/ethernet/brocade/bna/bna_tx_rx.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
index 57cd1bf..3c07064 100644
--- a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
+++ b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
@@ -1419,7 +1419,7 @@ static void bna_rx_sm_start_wait_entry(struct bna_rx *rx)
bna_bfi_rx_enet_start(rx);
}
-void
+static void
bna_rx_sm_stop_wait_entry(struct bna_rx *rx)
{
}
@@ -1472,7 +1472,7 @@ static void bna_rx_sm_rxf_start_wait_entry(struct bna_rx *rx)
bna_rxf_start(&rx->rxf);
}
-void
+static void
bna_rx_sm_rxf_stop_wait_entry(struct bna_rx *rx)
{
}
@@ -1528,7 +1528,7 @@ bna_rx_sm_start_stop_wait(struct bna_rx *rx, enum bna_rx_event event)
}
}
-void
+static void
bna_rx_sm_started_entry(struct bna_rx *rx)
{
struct bna_rxp *rxp;
@@ -1593,12 +1593,12 @@ static void bna_rx_sm_rxf_start_wait(struct bna_rx *rx,
}
}
-void
+static void
bna_rx_sm_cleanup_wait_entry(struct bna_rx *rx)
{
}
-void
+static void
bna_rx_sm_cleanup_wait(struct bna_rx *rx, enum bna_rx_event event)
{
switch (event) {
--
1.7.10.4
^ permalink raw reply related
* [PATCH v2 4/4] USBNET: ax88179_178a: enable tso if usb host supports sg dma
From: Ming Lei @ 2013-08-05 8:47 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, Sarah Sharp, netdev, linux-usb, Ming Lei,
Eric Dumazet, Ben Hutchings, Grant Grundler, Alan Stern,
Freddy Xin
In-Reply-To: <1375692423-9497-1-git-send-email-ming.lei@canonical.com>
This patch enables 'can_dma_sg' flag for ax88179_178a device
if the attached host controller supports building packet from
discontinuous buffers(DMA SG is possible), so TSO can be enabled
and skb fragment buffers can be passed to usb stack via urb->sg
directly.
With the patch, system CPU utilization decreased ~50% and throughput
increased by ~10% when doing iperf client test on one ARM A15 dual
core board.
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Cc: Grant Grundler <grundler@google.com>
Cc: Oliver Neukum <oneukum@suse.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Freddy Xin <freddy@asix.com.tw>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/ax88179_178a.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index fb0caa2..7a96326 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1031,12 +1031,20 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
dev->mii.phy_id = 0x03;
dev->mii.supports_gmii = 1;
+ if (usb_device_no_sg_constraint(dev->udev))
+ dev->can_dma_sg = 1;
+
dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
NETIF_F_RXCSUM;
dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
NETIF_F_RXCSUM;
+ if (dev->can_dma_sg) {
+ dev->net->features |= NETIF_F_SG | NETIF_F_TSO;
+ dev->net->hw_features |= NETIF_F_SG | NETIF_F_TSO;
+ }
+
/* Enable checksum offload */
*tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |
AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6;
@@ -1310,6 +1318,10 @@ static int ax88179_reset(struct usbnet *dev)
dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
NETIF_F_RXCSUM;
+ if (dev->can_dma_sg) {
+ dev->net->features |= NETIF_F_SG | NETIF_F_TSO;
+ dev->net->hw_features |= NETIF_F_SG | NETIF_F_TSO;
+ }
/* Enable checksum offload */
*tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 3/4] USBNET: support DMA SG
From: Ming Lei @ 2013-08-05 8:47 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, Sarah Sharp, netdev, linux-usb, Ming Lei,
Eric Dumazet, Ben Hutchings, Grant Grundler, Freddy Xin,
Alan Stern
In-Reply-To: <1375692423-9497-1-git-send-email-ming.lei@canonical.com>
This patch introduces support of DMA SG if the USB host controller
which usbnet device is attached to is capable of building packet from
discontinuous buffers.
The patch supports passing the skb fragment buffers to usb stack directly
via urb->sg.
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Cc: Grant Grundler <grundler@google.com>
Cc: Freddy Xin <freddy@asix.com.tw>
Cc: Oliver Neukum <oneukum@suse.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/usbnet.c | 39 +++++++++++++++++++++++++++++++++++++--
include/linux/usb/usbnet.h | 1 +
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index e4811d7..615d78e 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1232,6 +1232,37 @@ EXPORT_SYMBOL_GPL(usbnet_tx_timeout);
/*-------------------------------------------------------------------------*/
+static int build_dma_sg(const struct sk_buff *skb, struct urb *urb)
+{
+ unsigned num_sgs, total_len = 0;
+ int i, s = 0;
+
+ num_sgs = skb_shinfo(skb)->nr_frags + 1;
+ if (num_sgs == 1)
+ return 0;
+
+ urb->sg = kmalloc(num_sgs * sizeof(struct scatterlist), GFP_ATOMIC);
+ if (!urb->sg)
+ return -ENOMEM;
+
+ urb->num_sgs = num_sgs;
+ sg_init_table(urb->sg, urb->num_sgs);
+
+ sg_set_buf(&urb->sg[s++], skb->data, skb_headlen(skb));
+ total_len += skb_headlen(skb);
+
+ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
+ struct skb_frag_struct *f = &skb_shinfo(skb)->frags[i];
+
+ total_len += skb_frag_size(f);
+ sg_set_page(&urb->sg[i + s], f->page.p, f->size,
+ f->page_offset);
+ }
+ urb->transfer_buffer_length = total_len;
+
+ return 1;
+}
+
netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
struct net_device *net)
{
@@ -1258,7 +1289,6 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
goto drop;
}
}
- length = skb->len;
if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
netif_dbg(dev, tx_err, dev->net, "no urb\n");
@@ -1268,10 +1298,14 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
entry = (struct skb_data *) skb->cb;
entry->urb = urb;
entry->dev = dev;
- entry->length = length;
usb_fill_bulk_urb (urb, dev->udev, dev->out,
skb->data, skb->len, tx_complete, skb);
+ if (dev->can_dma_sg) {
+ if (build_dma_sg(skb, urb) < 0)
+ goto drop;
+ }
+ entry->length = length = urb->transfer_buffer_length;
/* don't assume the hardware handles USB_ZERO_PACKET
* NOTE: strictly conforming cdc-ether devices should expect
@@ -1391,6 +1425,7 @@ static void usbnet_bh (unsigned long param)
rx_process (dev, skb);
continue;
case tx_done:
+ kfree(entry->urb->sg);
case rx_cleanup:
usb_free_urb (entry->urb);
dev_kfree_skb (skb);
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 8fbc008..9cb2fe8 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -35,6 +35,7 @@ struct usbnet {
unsigned char suspend_count;
unsigned char pkt_cnt, pkt_err;
unsigned short rx_qlen, tx_qlen;
+ unsigned can_dma_sg:1;
/* i/o info: pipes etc */
unsigned in, out;
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 1/4] USB: introduce usb_device_no_sg_constraint() helper
From: Ming Lei @ 2013-08-05 8:47 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, Sarah Sharp, netdev, linux-usb, Ming Lei,
Alan Stern
In-Reply-To: <1375692423-9497-1-git-send-email-ming.lei@canonical.com>
Some host controllers(such as xHCI) can support building
packet from discontinuous buffers, so introduce one flag
and helper for this kind of host controllers, then the
feature can help some applications(such as usbnet) by
supporting arbitrary length of sg buffers.
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/usb/core/urb.c | 3 ++-
include/linux/usb.h | 11 ++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index e75115a..c77ec78 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -414,7 +414,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
urb->iso_frame_desc[n].status = -EXDEV;
urb->iso_frame_desc[n].actual_length = 0;
}
- } else if (dev->speed != USB_SPEED_WIRELESS && urb->num_sgs) {
+ } else if (urb->num_sgs && !urb->dev->bus->no_sg_constraint &&
+ dev->speed != USB_SPEED_WIRELESS) {
struct scatterlist *sg;
int i;
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 84f14e2..46cc0f7 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -337,6 +337,7 @@ struct usb_bus {
* the ep queue on a short transfer
* with the URB_SHORT_NOT_OK flag set.
*/
+ unsigned no_sg_constraint:1; /* no sg constraint */
unsigned sg_tablesize; /* 0 or largest number of sg list entries */
int devnum_next; /* Next open device number in
@@ -684,6 +685,14 @@ static inline bool usb_device_supports_ltm(struct usb_device *udev)
return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
}
+static inline bool usb_device_no_sg_constraint(struct usb_device *udev)
+{
+ if (udev && udev->bus && udev->bus->no_sg_constraint)
+ return true;
+ else
+ return false;
+}
+
/*-------------------------------------------------------------------------*/
@@ -1249,7 +1258,7 @@ typedef void (*usb_complete_t)(struct urb *);
* transfer_buffer.
* @sg: scatter gather buffer list, the buffer size of each element in
* the list (except the last) must be divisible by the endpoint's
- * max packet size
+ * max packet size if no_sg_constraint isn't set in 'struct usb_bus'
* @num_mapped_sgs: (internal) number of mapped sg entries
* @num_sgs: number of entries in the sg list
* @transfer_buffer_length: How big is transfer_buffer. The transfer may
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 0/4] USB & USBNET: loose SG check and support usbnet DMA SG
From: Ming Lei @ 2013-08-05 8:46 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, Sarah Sharp, netdev, linux-usb
Hi,
This patchset allows drivers to pass sg buffers which size can't be divided
by max packet size of endpoint if the host controllers(such ax xHCI) support
this kind of sg buffers.
Previously we added check[1] on the situation and don't allow these sg buffers
passed to USB HCD, looks the check is too strict to make use of new feature of
new hardware(xHCI) for some applications(such as network stack) which can't
provide this kind of sg buffers to usbnet driver, so the patch looses the check
in case that the host controller supports it.
Patch 3/4 implements DMA SG on usbnet driver, and patch 4/4 uses it on ax88179_178a
USB3 NIC for supporting TSO, so both CPU utilization and tx throughput can be
improved with TSO and DMA SG in case of the USB NIC is attached to xHCI controller.
This patchset depends on both net-next and usb-next tree, so hope David and Greg
to figure out one elegent way to merge it.
[1], http://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/commit/?h=usb-next&id=10e232c597ac757e7f8600649f7e872e86de190f
V2:
- add missed kfree(urb->sg) in 3/4
- rename no_sg_limit as no_sg_constraint as suggested by Alan
V1:
- introduce and apply usb_device_no_sg_limit() helper as suggested by Greg
- simplify patch 4/4 against Eric Dumazet's patch(ax88179_178a: avoid copy of tx tcp packets)
- don't pass usbnet header as sg buffer
drivers/net/usb/ax88179_178a.c | 12 ++++++++++++
drivers/net/usb/usbnet.c | 39 +++++++++++++++++++++++++++++++++++++--
drivers/usb/core/urb.c | 3 ++-
drivers/usb/host/xhci.c | 4 ++++
include/linux/usb.h | 11 ++++++++++-
include/linux/usb/usbnet.h | 1 +
6 files changed, 66 insertions(+), 4 deletions(-)
Thanks,
--
Ming Lei
^ permalink raw reply
* [PATCH v2 2/4] USB: XHCI: mark no_sg_constraint
From: Ming Lei @ 2013-08-05 8:47 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, Sarah Sharp, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, Ming Lei, Alan Stern
In-Reply-To: <1375692423-9497-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
This patch marks all xHCI controllers as no_sg_constraint
since xHCI supports building packet from discontinuous buffers.
Cc: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
Acked-by: Sarah Sharp <sarah.a.sharp-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
drivers/usb/host/xhci.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2c49f00..6e2ac57 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4841,6 +4841,10 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
/* Accept arbitrarily long scatter-gather lists */
hcd->self.sg_tablesize = ~0;
+
+ /* support to build packet from discontinuous buffers */
+ hcd->self.no_sg_constraint = 1;
+
/* XHCI controllers don't stop the ep queue on short packets :| */
hcd->self.no_stop_on_short = 1;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* Re: [PATCHv3] bridge: disable snooping if there is no querier
From: Paul Bolle @ 2013-08-05 8:41 UTC (permalink / raw)
To: David Miller
Cc: linus.luessing, bridge, stephen, netdev, linux-kernel, herbert,
amwang, linux
In-Reply-To: <20130731.174037.1794753574143053874.davem@davemloft.net>
On Wed, 2013-07-31 at 17:40 -0700, David Miller wrote:
> > If there is no querier on a link then we won't get periodic reports and
> > therefore won't be able to learn about multicast listeners behind ports,
> > potentially leading to lost multicast packets, especially for multicast
> > listeners that joined before the creation of the bridge.
> >
> > These lost multicast packets can appear since c5c23260594
> > ("bridge: Add multicast_querier toggle and disable queries by default")
> > in particular.
> >
> > With this patch we are flooding multicast packets if our querier is
> > disabled and if we didn't detect any other querier.
> >
> > A grace period of the Maximum Response Delay of the querier is added to
> > give multicast responses enough time to arrive and to be learned from
> > before disabling the flooding behaviour again.
> >
> > Signed-off-by: Linus Lüssing <linus.luessing@web.de>
>
> Looks good, applied, thanks Linus.
0) This patch is part of v3.11-rc4 as commit b00589af3b0. It introduced
a GCC warning:
net/bridge/br_multicast.c: In function ‘br_multicast_rcv’:
net/bridge/br_multicast.c:1081:36: warning: ‘max_delay’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/bridge/br_multicast.c:1178:16: note: ‘max_delay’ was declared here
1) Summarized, the code reads:
unsigned long max_delay;
if (skb->len == sizeof(*mld))
max_delay = msecs_to_jiffies(ntohs(mld->mld_maxdelay));
else if (skb->len >= sizeof(*mld2q))
max_delay = mld2q->mld2q_mrc ? MLDV2_MRC(ntohs(mld2q->mld2q_mrc)) : 1;
br_multicast_query_received(br, port, !ipv6_addr_any(&ip6h->saddr),
max_delay);
So GCC notices that max_delay is still uninitialized if skb->len is
neither equal to sizeof(*mld) nor equal or bigger than sizeof(*mld2q).
To me it looks GCC is right here. At least, it is not obvious that
max_delay will actually not be used in br_multicast_query_received() if
it still is uninitialized.
2) I'm entirely unfamiliar to this code. So I can't say how this warning
might be silenced.
Paul Bolle
^ permalink raw reply
* Re: [PATCH v5] net/phy: micrel: Add OF configuration support for ksz9021
From: Sean Cross @ 2013-08-05 8:12 UTC (permalink / raw)
To: Sascha Hauer
Cc: Duan Fugang-B38611, netdev@vger.kernel.org,
devicetree@vger.kernel.org, David Miller,
stephen@networkplumber.org, Steven Rostedt
In-Reply-To: <20130805075846.GJ26614@pengutronix.de>
--
Sean Cross
On Monday, August 5, 2013 at 3:58 PM, Sascha Hauer wrote:
> On Mon, Aug 05, 2013 at 07:04:08AM +0000, Sean Cross wrote:
> > Some boards require custom PHY configuration, for example due to trace
> > length differences. Add the ability to configure these registers in
> > order to get the PHY to function on boards that need it.
> >
> > Because PHYs are auto-detected based on MDIO device IDs, allow PHY
> > configuration to be specified in the parent Ethernet device node if no
> > PHY device node is present.
> >
> > Signed-off-by: Sean Cross <xobs@kosagi.com (mailto:xobs@kosagi.com)>
> > ---
> > .../devicetree/bindings/net/micrel-ksz9021.txt | 49 ++++++++++
> > drivers/net/phy/micrel.c | 101 +++++++++++++++++++-
> > 2 files changed, 149 insertions(+), 1 deletion(-)
> > create mode 100644 Documentation/devicetree/bindings/net/micrel-ksz9021.txt
> >
> > diff --git a/Documentation/devicetree/bindings/net/micrel-ksz9021.txt b/Documentation/devicetree/bindings/net/micrel-ksz9021.txt
> > new file mode 100644
> > index 0000000..338a7e2
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/micrel-ksz9021.txt
> > @@ -0,0 +1,49 @@
> > +Micrel KSZ9021 Gigabit Ethernet PHY
> > +
> > +Some boards require special tuning values, particularly when it comes to
> > +clock delays. You can specify clock delay values by adding
> > +micrel-specific properties to an Ethernet OF device node.
> > +
> > +All skew control options are specified in picoseconds. The minimum
> > +value is 0, and the maximum value is 3000.
> > +
> > +Optional properties:
> > + - rxc-skew : Skew control of RXC pad
> > + - rxdv-skew : Skew control of RX CTL pad
> > + - txc-skew : Skew control of TXC pad
> > + - txen-skew : Skew control of TX_CTL pad
> > + - rxd0-skew : Skew control of RX data 0 pad
> > + - rxd1-skew : Skew control of RX data 1 pad
> > + - rxd2-skew : Skew control of RX data 2 pad
> > + - rxd3-skew : Skew control of RX data 3 pad
> > + - txd0-skew : Skew control of TX data 0 pad
> > + - txd1-skew : Skew control of TX data 1 pad
> > + - txd2-skew : Skew control of TX data 2 pad
> > + - txd3-skew : Skew control of TX data 3 pad
> > +
> > +Examples:
> > +
> > + /* Attach to an Ethernet device with autodetected PHY */
> > + &enet {
> > + rxc-skew = <3000>; // picoseconds
> > + rxdv-skew = <0>; // picoseconds
> > + txc-skew = <3000>; // picoseconds
> > + txen-skew = <0>; // picoseconds
> > + status = "okay";
> > + };
> > +
> > + /* Attach to an explicitly-specified PHY */
> > + mdio {
> > + phy0: ethernet-phy@0 {
> > + rxc-skew = <3000>; // picoseconds
> > + rxdv-skew = <0>; // picoseconds
> > + txc-skew = <3000>; // picoseconds
> > + txen-skew = <0>; // picoseconds
> > + reg = <0>;
> > + };
> > + };
> > + ethernet@70000 {
> > + status = "okay";
> > + phy = <&phy0>;
> > + phy-mode = "rgmii-id";
> > + };
> > diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> > index 2510435..3e60ed0 100644
> > --- a/drivers/net/phy/micrel.c
> > +++ b/drivers/net/phy/micrel.c
> > @@ -25,6 +25,7 @@
> > #include <linux/module.h>
> > #include <linux/phy.h>
> > #include <linux/micrel_phy.h>
> > +#include <linux/of.h>
> >
> > /* Operation Mode Strap Override */
> > #define MII_KSZPHY_OMSO 0x16
> > @@ -53,6 +54,18 @@
> > #define KS8737_CTRL_INT_ACTIVE_HIGH (1 << 14)
> > #define KSZ8051_RMII_50MHZ_CLK (1 << 7)
> >
> > +/* Write/read to/from extended registers */
> > +#define MII_KSZPHY_EXTREG 0x0b
> > +#define KSZPHY_EXTREG_WRITE 0x8000
> > +
> > +#define MII_KSZPHY_EXTREG_WRITE 0x0c
> > +#define MII_KSZPHY_EXTREG_READ 0x0d
> > +
> > +/* Extended registers */
> > +#define MII_KSZPHY_CLK_CONTROL_PAD_SKEW 0x104
> > +#define MII_KSZPHY_RX_DATA_PAD_SKEW 0x105
> > +#define MII_KSZPHY_TX_DATA_PAD_SKEW 0x106
> > +
> > static int ksz_config_flags(struct phy_device *phydev)
> > {
> > int regval;
> > @@ -65,6 +78,20 @@ static int ksz_config_flags(struct phy_device *phydev)
> > return 0;
> > }
> >
> > +static int kszphy_extended_write(struct phy_device *phydev,
> > + u32 regnum, u16 val)
> > +{
> > + phy_write(phydev, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | regnum);
> > + return phy_write(phydev, MII_KSZPHY_EXTREG_WRITE, val);
> > +}
> > +
> > +static int kszphy_extended_read(struct phy_device *phydev,
> > + u32 regnum)
> > +{
> > + phy_write(phydev, MII_KSZPHY_EXTREG, regnum);
> > + return phy_read(phydev, MII_KSZPHY_EXTREG_READ);
> > +}
> > +
> > static int kszphy_ack_interrupt(struct phy_device *phydev)
> > {
> > /* bit[7..0] int status, which is a read and clear register. */
> > @@ -141,6 +168,78 @@ static int ks8051_config_init(struct phy_device *phydev)
> > return rc < 0 ? rc : 0;
> > }
> >
> > +static int ksz9021_load_values_from_of(struct phy_device *phydev,
> > + struct device_node *of_node, u16 reg,
> > + char *field1, char *field2,
> > + char *field3, char *field4)
> > +{
> > + int val1 = -1;
> > + int val2 = -2;
> > + int val3 = -3;
> > + int val4 = -4;
> > + int newval;
> > + int matches = 0;
> > +
> > + if (!of_property_read_u32(of_node, field1, &val1))
> > + matches++;
> > +
> > + if (!of_property_read_u32(of_node, field2, &val2))
> > + matches++;
> > +
> > + if (!of_property_read_u32(of_node, field3, &val3))
> > + matches++;
> > +
> > + if (!of_property_read_u32(of_node, field4, &val4))
> > + matches++;
> > +
> > + if (!matches)
> > + return 0;
> > +
> > + if (matches < 4)
> > + newval = kszphy_extended_read(phydev, reg);
> > + else
> > + newval = 0;
>
>
>
> Just initialize newval with the reset default of this register. It will
> make this function easier. Also this two step read from dt and evaluate
> afterwards seems unnecessary.
The documentation seems inaccurate here. My datasheet says it defaults to 0x0111, but when I check it for myself it comes out 0x7777. Which value do you think I should take?
> > +
> > + if (val1 != -1)
> > + newval = ((newval & 0xfff0) | ((val1/200)&0xf) << 0);
> > +
> > + if (val2 != -1)
> > + newval = ((newval & 0xff0f) | ((val2/200)&0xf) << 4);
> > +
> > + if (val3 != -1)
> > + newval = ((newval & 0xf0ff) | ((val3/200)&0xf) << 8);
> > +
> > + if (val4 != -1)
> > + newval = ((newval & 0x0fff) | ((val4/200)&0xf) << 12);
> > +
> > + return kszphy_extended_write(phydev, reg, newval);
> > +}
> > +
> > +static int ksz9021_config_init(struct phy_device *phydev)
> > +{
> > + struct device *dev = &phydev->dev;
> > + struct device_node *of_node = dev->of_node;
> > +
> > + if (!of_node && dev->parent->of_node)
> > + of_node = dev->parent->of_node;
> > +
> > + if (of_node) {
> > + ksz9021_load_values_from_of(phydev, of_node,
> > + MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
> > + "txen-skew", "txc-skew",
> > + "rxdv-skew", "rxc-skew");
> > + ksz9021_load_values_from_of(phydev, of_node,
> > + MII_KSZPHY_RX_DATA_PAD_SKEW,
> > + "rxd0-skew", "rxd1-skew",
> > + "rxd2-skew", "rxd3-skew");
> > + ksz9021_load_values_from_of(phydev, of_node,
> > + MII_KSZPHY_TX_DATA_PAD_SKEW,
> > + "txd0-skew", "txd1-skew",
> > + "txd2-skew", "txd3-skew");
>
>
>
> Are you sure this register exists? It's not mentioned in my datasheet,
> only the first two are.
>
I'm very sure the register exists. There's a hole in the documentation where the TX control register should exist. Furthermore, we measured that changing values in this register adjusted the TX skew on the RG-MII wires, and on our board at least, adjusting these values yields increased performance.
^ permalink raw reply
* Re: [PATCH net 1/2] vlan: make vlan_dev_real_dev work over stacked vlans
From: Nikolay Aleksandrov @ 2013-08-05 8:12 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev, davem, fubar, jhs
In-Reply-To: <20130805065855.GF22756@redhat.com>
On 08/05/2013 08:58 AM, Veaceslav Falico wrote:
> On Sun, Aug 04, 2013 at 04:17:43AM +0200, Nikolay Aleksandrov wrote:
>> On 08/03/2013 10:07 PM, Nikolay Aleksandrov wrote:
<snip>
>> I have one question - why not make it possible to call vlan_dev_real_dev()
>> with any device (vlan/non-vlan) and make it return a real device in all
>> cases (e.g. if it's a non-vlan device simply return it) ?
>> In the terms of the code above - simply change:
>> struct net_device *ret = vlan_dev_priv(dev)->real_dev;
>> with
>> struct net_device *ret = dev;
>>
>> This way we'll be able to simplify calls like if (is_vlan_dev(dev)) (or the
>> flag check alternative of this) to just vlan_dev_real_dev(). The old call
>> sites of this function will still work properly.
>
> I think it'll be a bit harder to understand the callers' code. Now it
> always has the logic "wait, we might be having a vlan here, so lets verify
> if it's really a vlan and if yes - get the real device". However with this
> approach it might look like "we *really* have a vlan here - so lets get the
> real device" (because of the function name - vlan_dev_real_dev) - which is
> wrong. And it doesn't really provide any speed/size improvements - so it's
> kind of useless.
>
It's not used in fast paths, this suggestion was purely about saving some
lines and indentation levels. And you can still use it the old way if you
prefer it.
> So, unless a better function name can be found (which I can't come up with
> - dev_or_strip_vlan()? dev_devlanitize()? :) ) - I'd stay with the current
> version. Though, again, I don't have a strong opinion on this.
It's all the same to me as well, I've wasted enough time on these simple
patches so I'd rather see them in (if accepted) than argue about semantics :-)
>
>>
>> Nik
^ permalink raw reply
* Re: [PATCH v5] net/phy: micrel: Add OF configuration support for ksz9021
From: Sascha Hauer @ 2013-08-05 7:58 UTC (permalink / raw)
To: Sean Cross
Cc: Duan Fugang-B38611, netdev@vger.kernel.org,
devicetree@vger.kernel.org, David Miller,
stephen@networkplumber.org, Steven Rostedt
In-Reply-To: <1375686248-17995-2-git-send-email-xobs@kosagi.com>
On Mon, Aug 05, 2013 at 07:04:08AM +0000, Sean Cross wrote:
> Some boards require custom PHY configuration, for example due to trace
> length differences. Add the ability to configure these registers in
> order to get the PHY to function on boards that need it.
>
> Because PHYs are auto-detected based on MDIO device IDs, allow PHY
> configuration to be specified in the parent Ethernet device node if no
> PHY device node is present.
>
> Signed-off-by: Sean Cross <xobs@kosagi.com>
> ---
> .../devicetree/bindings/net/micrel-ksz9021.txt | 49 ++++++++++
> drivers/net/phy/micrel.c | 101 +++++++++++++++++++-
> 2 files changed, 149 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/devicetree/bindings/net/micrel-ksz9021.txt
>
> diff --git a/Documentation/devicetree/bindings/net/micrel-ksz9021.txt b/Documentation/devicetree/bindings/net/micrel-ksz9021.txt
> new file mode 100644
> index 0000000..338a7e2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/micrel-ksz9021.txt
> @@ -0,0 +1,49 @@
> +Micrel KSZ9021 Gigabit Ethernet PHY
> +
> +Some boards require special tuning values, particularly when it comes to
> +clock delays. You can specify clock delay values by adding
> +micrel-specific properties to an Ethernet OF device node.
> +
> +All skew control options are specified in picoseconds. The minimum
> +value is 0, and the maximum value is 3000.
> +
> +Optional properties:
> + - rxc-skew : Skew control of RXC pad
> + - rxdv-skew : Skew control of RX CTL pad
> + - txc-skew : Skew control of TXC pad
> + - txen-skew : Skew control of TX_CTL pad
> + - rxd0-skew : Skew control of RX data 0 pad
> + - rxd1-skew : Skew control of RX data 1 pad
> + - rxd2-skew : Skew control of RX data 2 pad
> + - rxd3-skew : Skew control of RX data 3 pad
> + - txd0-skew : Skew control of TX data 0 pad
> + - txd1-skew : Skew control of TX data 1 pad
> + - txd2-skew : Skew control of TX data 2 pad
> + - txd3-skew : Skew control of TX data 3 pad
> +
> +Examples:
> +
> + /* Attach to an Ethernet device with autodetected PHY */
> + &enet {
> + rxc-skew = <3000>; // picoseconds
> + rxdv-skew = <0>; // picoseconds
> + txc-skew = <3000>; // picoseconds
> + txen-skew = <0>; // picoseconds
> + status = "okay";
> + };
> +
> + /* Attach to an explicitly-specified PHY */
> + mdio {
> + phy0: ethernet-phy@0 {
> + rxc-skew = <3000>; // picoseconds
> + rxdv-skew = <0>; // picoseconds
> + txc-skew = <3000>; // picoseconds
> + txen-skew = <0>; // picoseconds
> + reg = <0>;
> + };
> + };
> + ethernet@70000 {
> + status = "okay";
> + phy = <&phy0>;
> + phy-mode = "rgmii-id";
> + };
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 2510435..3e60ed0 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -25,6 +25,7 @@
> #include <linux/module.h>
> #include <linux/phy.h>
> #include <linux/micrel_phy.h>
> +#include <linux/of.h>
>
> /* Operation Mode Strap Override */
> #define MII_KSZPHY_OMSO 0x16
> @@ -53,6 +54,18 @@
> #define KS8737_CTRL_INT_ACTIVE_HIGH (1 << 14)
> #define KSZ8051_RMII_50MHZ_CLK (1 << 7)
>
> +/* Write/read to/from extended registers */
> +#define MII_KSZPHY_EXTREG 0x0b
> +#define KSZPHY_EXTREG_WRITE 0x8000
> +
> +#define MII_KSZPHY_EXTREG_WRITE 0x0c
> +#define MII_KSZPHY_EXTREG_READ 0x0d
> +
> +/* Extended registers */
> +#define MII_KSZPHY_CLK_CONTROL_PAD_SKEW 0x104
> +#define MII_KSZPHY_RX_DATA_PAD_SKEW 0x105
> +#define MII_KSZPHY_TX_DATA_PAD_SKEW 0x106
> +
> static int ksz_config_flags(struct phy_device *phydev)
> {
> int regval;
> @@ -65,6 +78,20 @@ static int ksz_config_flags(struct phy_device *phydev)
> return 0;
> }
>
> +static int kszphy_extended_write(struct phy_device *phydev,
> + u32 regnum, u16 val)
> +{
> + phy_write(phydev, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | regnum);
> + return phy_write(phydev, MII_KSZPHY_EXTREG_WRITE, val);
> +}
> +
> +static int kszphy_extended_read(struct phy_device *phydev,
> + u32 regnum)
> +{
> + phy_write(phydev, MII_KSZPHY_EXTREG, regnum);
> + return phy_read(phydev, MII_KSZPHY_EXTREG_READ);
> +}
> +
> static int kszphy_ack_interrupt(struct phy_device *phydev)
> {
> /* bit[7..0] int status, which is a read and clear register. */
> @@ -141,6 +168,78 @@ static int ks8051_config_init(struct phy_device *phydev)
> return rc < 0 ? rc : 0;
> }
>
> +static int ksz9021_load_values_from_of(struct phy_device *phydev,
> + struct device_node *of_node, u16 reg,
> + char *field1, char *field2,
> + char *field3, char *field4)
> +{
> + int val1 = -1;
> + int val2 = -2;
> + int val3 = -3;
> + int val4 = -4;
> + int newval;
> + int matches = 0;
> +
> + if (!of_property_read_u32(of_node, field1, &val1))
> + matches++;
> +
> + if (!of_property_read_u32(of_node, field2, &val2))
> + matches++;
> +
> + if (!of_property_read_u32(of_node, field3, &val3))
> + matches++;
> +
> + if (!of_property_read_u32(of_node, field4, &val4))
> + matches++;
> +
> + if (!matches)
> + return 0;
> +
> + if (matches < 4)
> + newval = kszphy_extended_read(phydev, reg);
> + else
> + newval = 0;
Just initialize newval with the reset default of this register. It will
make this function easier. Also this two step read from dt and evaluate
afterwards seems unnecessary.
> +
> + if (val1 != -1)
> + newval = ((newval & 0xfff0) | ((val1/200)&0xf) << 0);
> +
> + if (val2 != -1)
> + newval = ((newval & 0xff0f) | ((val2/200)&0xf) << 4);
> +
> + if (val3 != -1)
> + newval = ((newval & 0xf0ff) | ((val3/200)&0xf) << 8);
> +
> + if (val4 != -1)
> + newval = ((newval & 0x0fff) | ((val4/200)&0xf) << 12);
> +
> + return kszphy_extended_write(phydev, reg, newval);
> +}
> +
> +static int ksz9021_config_init(struct phy_device *phydev)
> +{
> + struct device *dev = &phydev->dev;
> + struct device_node *of_node = dev->of_node;
> +
> + if (!of_node && dev->parent->of_node)
> + of_node = dev->parent->of_node;
> +
> + if (of_node) {
> + ksz9021_load_values_from_of(phydev, of_node,
> + MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
> + "txen-skew", "txc-skew",
> + "rxdv-skew", "rxc-skew");
> + ksz9021_load_values_from_of(phydev, of_node,
> + MII_KSZPHY_RX_DATA_PAD_SKEW,
> + "rxd0-skew", "rxd1-skew",
> + "rxd2-skew", "rxd3-skew");
> + ksz9021_load_values_from_of(phydev, of_node,
> + MII_KSZPHY_TX_DATA_PAD_SKEW,
> + "txd0-skew", "txd1-skew",
> + "txd2-skew", "txd3-skew");
Are you sure this register exists? It's not mentioned in my datasheet,
only the first two are.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply
* Re: [PATCH v5] net/phy: micrel: Add OF configuration support for ksz9021
From: Sean Cross @ 2013-08-05 7:54 UTC (permalink / raw)
To: Duan Fugang-B38611
Cc: Sascha Hauer, netdev@vger.kernel.org, devicetree@vger.kernel.org,
David Miller, stephen@networkplumber.org, Steven Rostedt
In-Reply-To: <9848F2DB572E5649BA045B288BE08FBE015EECA0@039-SN2MPN1-023.039d.mgd.msft.net>
--
Sean Cross
On Monday, August 5, 2013 at 3:41 PM, Duan Fugang-B38611 wrote:
> From: Sean Cross [mailto:xobs@kosagi.com]
> Data: Monday, August 05, 2013 3:04 PM
> > To: Sascha Hauer; Duan Fugang-B38611; netdev@vger.kernel.org (mailto:netdev@vger.kernel.org);
> > devicetree@vger.kernel.org (mailto:devicetree@vger.kernel.org)
> > Cc: David Miller; stephen@networkplumber.org (mailto:stephen@networkplumber.org); Steven Rostedt; Sean Cross
> > Subject: [PATCH v5] net/phy: micrel: Add OF configuration support for
> > ksz9021
> >
> > Some boards require custom PHY configuration, for example due to trace
> > length differences. Add the ability to configure these registers in order
> > to get the PHY to function on boards that need it.
> >
> > Because PHYs are auto-detected based on MDIO device IDs, allow PHY
> > configuration to be specified in the parent Ethernet device node if no PHY
> > device node is present.
> >
> > Signed-off-by: Sean Cross <xobs@kosagi.com (mailto:xobs@kosagi.com)>
> > ---
> > +static int ksz9021_load_values_from_of(struct phy_device *phydev,
> > + struct device_node *of_node, u16 reg,
> > + char *field1, char *field2,
> > + char *field3, char *field4)
> > +{
> > + int val1 = -1;
> > + int val2 = -2;
> > + int val3 = -3;
> > + int val4 = -4;
> > + int newval;
> > + int matches = 0;
> > +
> > + if (!of_property_read_u32(of_node, field1, &val1))
> > + matches++;
> > +
> > + if (!of_property_read_u32(of_node, field2, &val2))
> > + matches++;
> > +
> > + if (!of_property_read_u32(of_node, field3, &val3))
> > + matches++;
> > +
> > + if (!of_property_read_u32(of_node, field4, &val4))
> > + matches++;
> > +
> > + if (!matches)
> > + return 0;
> > +
> > + if (matches < 4)
> > + newval = kszphy_extended_read(phydev, reg);
> > + else
> > + newval = 0;
> > +
> > + if (val1 != -1)
> > + newval = ((newval & 0xfff0) | ((val1/200)&0xf) << 0);
> > +
> > + if (val2 != -1)
> > + newval = ((newval & 0xff0f) | ((val2/200)&0xf) << 4);
>
>
> Must be : Newval |= ...
> > +
> > + if (val3 != -1)
> > + newval = ((newval & 0xf0ff) | ((val3/200)&0xf) << 8);
>
>
> Must be : Newval |= ...
> > +
> > + if (val4 != -1)
> > + newval = ((newval & 0x0fff) | ((val4/200)&0xf) << 12);
>
>
> Must be : Newval |= ...
> > +
> > + return kszphy_extended_write(phydev, reg, newval); }
>
If all four fields are updated, then newval will start out as 0. If only a few fields are updated, then newval will start out with the previous value.
If a given field is mentioned in the device tree file, then its value will change to something other than -1. If the value remains at -1, then that particular field could not be found, and it should not be modified.
^ permalink raw reply
* RE: [PATCH v5] net/phy: micrel: Add OF configuration support for ksz9021
From: Duan Fugang-B38611 @ 2013-08-05 7:41 UTC (permalink / raw)
To: Sean Cross, Sascha Hauer, netdev@vger.kernel.org,
devicetree@vger.kernel.org
Cc: David Miller, stephen@networkplumber.org, Steven Rostedt
In-Reply-To: <1375686248-17995-2-git-send-email-xobs@kosagi.com>
From: Sean Cross [mailto:xobs@kosagi.com]
Data: Monday, August 05, 2013 3:04 PM
> To: Sascha Hauer; Duan Fugang-B38611; netdev@vger.kernel.org;
> devicetree@vger.kernel.org
> Cc: David Miller; stephen@networkplumber.org; Steven Rostedt; Sean Cross
> Subject: [PATCH v5] net/phy: micrel: Add OF configuration support for
> ksz9021
>
> Some boards require custom PHY configuration, for example due to trace
> length differences. Add the ability to configure these registers in order
> to get the PHY to function on boards that need it.
>
> Because PHYs are auto-detected based on MDIO device IDs, allow PHY
> configuration to be specified in the parent Ethernet device node if no PHY
> device node is present.
>
> Signed-off-by: Sean Cross <xobs@kosagi.com>
> ---
> +static int ksz9021_load_values_from_of(struct phy_device *phydev,
> + struct device_node *of_node, u16 reg,
> + char *field1, char *field2,
> + char *field3, char *field4)
> +{
> + int val1 = -1;
> + int val2 = -2;
> + int val3 = -3;
> + int val4 = -4;
> + int newval;
> + int matches = 0;
> +
> + if (!of_property_read_u32(of_node, field1, &val1))
> + matches++;
> +
> + if (!of_property_read_u32(of_node, field2, &val2))
> + matches++;
> +
> + if (!of_property_read_u32(of_node, field3, &val3))
> + matches++;
> +
> + if (!of_property_read_u32(of_node, field4, &val4))
> + matches++;
> +
> + if (!matches)
> + return 0;
> +
> + if (matches < 4)
> + newval = kszphy_extended_read(phydev, reg);
> + else
> + newval = 0;
> +
> + if (val1 != -1)
> + newval = ((newval & 0xfff0) | ((val1/200)&0xf) << 0);
> +
> + if (val2 != -1)
> + newval = ((newval & 0xff0f) | ((val2/200)&0xf) << 4);
Must be : Newval |= ...
> +
> + if (val3 != -1)
> + newval = ((newval & 0xf0ff) | ((val3/200)&0xf) << 8);
Must be : Newval |= ...
> +
> + if (val4 != -1)
> + newval = ((newval & 0x0fff) | ((val4/200)&0xf) << 12);
Must be : Newval |= ...
> +
> + return kszphy_extended_write(phydev, reg, newval); }
^ permalink raw reply
* [PATCH v5] net/phy: micrel: Add OF configuration support for ksz9021
From: Sean Cross @ 2013-08-05 7:04 UTC (permalink / raw)
To: Sascha Hauer, Duan Fugang-B38611, netdev@vger.kernel.org,
devicetree@vger.kernel.org
Cc: David Miller, stephen@networkplumber.org, Steven Rostedt,
Sean Cross
In-Reply-To: <1375686248-17995-1-git-send-email-xobs@kosagi.com>
Some boards require custom PHY configuration, for example due to trace
length differences. Add the ability to configure these registers in
order to get the PHY to function on boards that need it.
Because PHYs are auto-detected based on MDIO device IDs, allow PHY
configuration to be specified in the parent Ethernet device node if no
PHY device node is present.
Signed-off-by: Sean Cross <xobs@kosagi.com>
---
.../devicetree/bindings/net/micrel-ksz9021.txt | 49 ++++++++++
drivers/net/phy/micrel.c | 101 +++++++++++++++++++-
2 files changed, 149 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/micrel-ksz9021.txt
diff --git a/Documentation/devicetree/bindings/net/micrel-ksz9021.txt b/Documentation/devicetree/bindings/net/micrel-ksz9021.txt
new file mode 100644
index 0000000..338a7e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/micrel-ksz9021.txt
@@ -0,0 +1,49 @@
+Micrel KSZ9021 Gigabit Ethernet PHY
+
+Some boards require special tuning values, particularly when it comes to
+clock delays. You can specify clock delay values by adding
+micrel-specific properties to an Ethernet OF device node.
+
+All skew control options are specified in picoseconds. The minimum
+value is 0, and the maximum value is 3000.
+
+Optional properties:
+ - rxc-skew : Skew control of RXC pad
+ - rxdv-skew : Skew control of RX CTL pad
+ - txc-skew : Skew control of TXC pad
+ - txen-skew : Skew control of TX_CTL pad
+ - rxd0-skew : Skew control of RX data 0 pad
+ - rxd1-skew : Skew control of RX data 1 pad
+ - rxd2-skew : Skew control of RX data 2 pad
+ - rxd3-skew : Skew control of RX data 3 pad
+ - txd0-skew : Skew control of TX data 0 pad
+ - txd1-skew : Skew control of TX data 1 pad
+ - txd2-skew : Skew control of TX data 2 pad
+ - txd3-skew : Skew control of TX data 3 pad
+
+Examples:
+
+ /* Attach to an Ethernet device with autodetected PHY */
+ &enet {
+ rxc-skew = <3000>; // picoseconds
+ rxdv-skew = <0>; // picoseconds
+ txc-skew = <3000>; // picoseconds
+ txen-skew = <0>; // picoseconds
+ status = "okay";
+ };
+
+ /* Attach to an explicitly-specified PHY */
+ mdio {
+ phy0: ethernet-phy@0 {
+ rxc-skew = <3000>; // picoseconds
+ rxdv-skew = <0>; // picoseconds
+ txc-skew = <3000>; // picoseconds
+ txen-skew = <0>; // picoseconds
+ reg = <0>;
+ };
+ };
+ ethernet@70000 {
+ status = "okay";
+ phy = <&phy0>;
+ phy-mode = "rgmii-id";
+ };
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 2510435..3e60ed0 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -25,6 +25,7 @@
#include <linux/module.h>
#include <linux/phy.h>
#include <linux/micrel_phy.h>
+#include <linux/of.h>
/* Operation Mode Strap Override */
#define MII_KSZPHY_OMSO 0x16
@@ -53,6 +54,18 @@
#define KS8737_CTRL_INT_ACTIVE_HIGH (1 << 14)
#define KSZ8051_RMII_50MHZ_CLK (1 << 7)
+/* Write/read to/from extended registers */
+#define MII_KSZPHY_EXTREG 0x0b
+#define KSZPHY_EXTREG_WRITE 0x8000
+
+#define MII_KSZPHY_EXTREG_WRITE 0x0c
+#define MII_KSZPHY_EXTREG_READ 0x0d
+
+/* Extended registers */
+#define MII_KSZPHY_CLK_CONTROL_PAD_SKEW 0x104
+#define MII_KSZPHY_RX_DATA_PAD_SKEW 0x105
+#define MII_KSZPHY_TX_DATA_PAD_SKEW 0x106
+
static int ksz_config_flags(struct phy_device *phydev)
{
int regval;
@@ -65,6 +78,20 @@ static int ksz_config_flags(struct phy_device *phydev)
return 0;
}
+static int kszphy_extended_write(struct phy_device *phydev,
+ u32 regnum, u16 val)
+{
+ phy_write(phydev, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | regnum);
+ return phy_write(phydev, MII_KSZPHY_EXTREG_WRITE, val);
+}
+
+static int kszphy_extended_read(struct phy_device *phydev,
+ u32 regnum)
+{
+ phy_write(phydev, MII_KSZPHY_EXTREG, regnum);
+ return phy_read(phydev, MII_KSZPHY_EXTREG_READ);
+}
+
static int kszphy_ack_interrupt(struct phy_device *phydev)
{
/* bit[7..0] int status, which is a read and clear register. */
@@ -141,6 +168,78 @@ static int ks8051_config_init(struct phy_device *phydev)
return rc < 0 ? rc : 0;
}
+static int ksz9021_load_values_from_of(struct phy_device *phydev,
+ struct device_node *of_node, u16 reg,
+ char *field1, char *field2,
+ char *field3, char *field4)
+{
+ int val1 = -1;
+ int val2 = -2;
+ int val3 = -3;
+ int val4 = -4;
+ int newval;
+ int matches = 0;
+
+ if (!of_property_read_u32(of_node, field1, &val1))
+ matches++;
+
+ if (!of_property_read_u32(of_node, field2, &val2))
+ matches++;
+
+ if (!of_property_read_u32(of_node, field3, &val3))
+ matches++;
+
+ if (!of_property_read_u32(of_node, field4, &val4))
+ matches++;
+
+ if (!matches)
+ return 0;
+
+ if (matches < 4)
+ newval = kszphy_extended_read(phydev, reg);
+ else
+ newval = 0;
+
+ if (val1 != -1)
+ newval = ((newval & 0xfff0) | ((val1/200)&0xf) << 0);
+
+ if (val2 != -1)
+ newval = ((newval & 0xff0f) | ((val2/200)&0xf) << 4);
+
+ if (val3 != -1)
+ newval = ((newval & 0xf0ff) | ((val3/200)&0xf) << 8);
+
+ if (val4 != -1)
+ newval = ((newval & 0x0fff) | ((val4/200)&0xf) << 12);
+
+ return kszphy_extended_write(phydev, reg, newval);
+}
+
+static int ksz9021_config_init(struct phy_device *phydev)
+{
+ struct device *dev = &phydev->dev;
+ struct device_node *of_node = dev->of_node;
+
+ if (!of_node && dev->parent->of_node)
+ of_node = dev->parent->of_node;
+
+ if (of_node) {
+ ksz9021_load_values_from_of(phydev, of_node,
+ MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
+ "txen-skew", "txc-skew",
+ "rxdv-skew", "rxc-skew");
+ ksz9021_load_values_from_of(phydev, of_node,
+ MII_KSZPHY_RX_DATA_PAD_SKEW,
+ "rxd0-skew", "rxd1-skew",
+ "rxd2-skew", "rxd3-skew");
+ ksz9021_load_values_from_of(phydev, of_node,
+ MII_KSZPHY_TX_DATA_PAD_SKEW,
+ "txd0-skew", "txd1-skew",
+ "txd2-skew", "txd3-skew");
+ }
+ return 0;
+}
+
#define KSZ8873MLL_GLOBAL_CONTROL_4 0x06
#define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX (1 << 6)
#define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED (1 << 4)
@@ -281,7 +380,7 @@ static struct phy_driver ksphy_driver[] = {
.name = "Micrel KSZ9021 Gigabit PHY",
.features = (PHY_GBIT_FEATURES | SUPPORTED_Pause),
.flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
- .config_init = kszphy_config_init,
+ .config_init = ksz9021_config_init,
.config_aneg = genphy_config_aneg,
.read_status = genphy_read_status,
.ack_interrupt = kszphy_ack_interrupt,
--
1.7.9.5
^ permalink raw reply related
* [PATCH v5] Add OF bindings to Micrel ksz9021 PHY
From: Sean Cross @ 2013-08-05 7:04 UTC (permalink / raw)
To: Sascha Hauer, Duan Fugang-B38611, netdev@vger.kernel.org,
devicetree@vger.kernel.org
Cc: David Miller, stephen@networkplumber.org, Steven Rostedt,
Sean Cross
Some boards require custom parameters be passed to the Micrel PHY.
Allow these boards to specify custom timing parameters in the device
tree node.
Changes since v4:
- Add an example of parameters on an mdio bus
- Specify values in picoseconds rather than as register values
v4 was accidentally unchanged from v3
Changes since v2:
- limited the scope to just ksz9021 rather than all PHYs
Changes since v1:
- removed redefinition of registers and addresses
Sean Cross (1):
net/phy: micrel: Add OF configuration support for ksz9021
.../devicetree/bindings/net/micrel-ksz9021.txt | 49 ++++++++++
drivers/net/phy/micrel.c | 101 +++++++++++++++++++-
2 files changed, 149 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/micrel-ksz9021.txt
--
1.7.9.5
^ permalink raw reply
* Re: [PATCH net 1/2] vlan: make vlan_dev_real_dev work over stacked vlans
From: Veaceslav Falico @ 2013-08-05 6:58 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: netdev, davem, fubar, jhs
In-Reply-To: <51FDB9C7.4090703@redhat.com>
On Sun, Aug 04, 2013 at 04:17:43AM +0200, Nikolay Aleksandrov wrote:
>On 08/03/2013 10:07 PM, Nikolay Aleksandrov wrote:
>> From: Nikolay Aleksandrov <Nikolay Aleksandrov nikolay@redhat.com>
>>
>> Sometimes we might have stacked vlans on top of each other, and we're
>> interested in the first non-vlan real device on the path, so transform
>> vlan_dev_real_dev to go over the stacked vlans and extract the first
>> non-vlan device.
>>
>> Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
>> ---
>> net/8021q/vlan_core.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
>> index 4a78c4d..6ee48aa 100644
>> --- a/net/8021q/vlan_core.c
>> +++ b/net/8021q/vlan_core.c
>> @@ -91,7 +91,12 @@ EXPORT_SYMBOL(__vlan_find_dev_deep);
>>
>> struct net_device *vlan_dev_real_dev(const struct net_device *dev)
>> {
>> - return vlan_dev_priv(dev)->real_dev;
>> + struct net_device *ret = vlan_dev_priv(dev)->real_dev;
>> +
>> + while (is_vlan_dev(ret))
>> + ret = vlan_dev_priv(ret)->real_dev;
>> +
>> + return ret;
>> }
>> EXPORT_SYMBOL(vlan_dev_real_dev);
>>
>>
>I have one question - why not make it possible to call vlan_dev_real_dev()
>with any device (vlan/non-vlan) and make it return a real device in all
>cases (e.g. if it's a non-vlan device simply return it) ?
>In the terms of the code above - simply change:
>struct net_device *ret = vlan_dev_priv(dev)->real_dev;
>with
>struct net_device *ret = dev;
>
>This way we'll be able to simplify calls like if (is_vlan_dev(dev)) (or the
>flag check alternative of this) to just vlan_dev_real_dev(). The old call
>sites of this function will still work properly.
I think it'll be a bit harder to understand the callers' code. Now it
always has the logic "wait, we might be having a vlan here, so lets verify
if it's really a vlan and if yes - get the real device". However with this
approach it might look like "we *really* have a vlan here - so lets get the
real device" (because of the function name - vlan_dev_real_dev) - which is
wrong. And it doesn't really provide any speed/size improvements - so it's
kind of useless.
So, unless a better function name can be found (which I can't come up with
- dev_or_strip_vlan()? dev_devlanitize()? :) ) - I'd stay with the current
version. Though, again, I don't have a strong opinion on this.
>
>Nik
^ permalink raw reply
* Re: [PATCH net] net: mlx5: fix sizeof usage in health_care's reg_handler
From: David Miller @ 2013-08-05 6:39 UTC (permalink / raw)
To: eli; +Cc: dborkman, netdev, ogerlitz
In-Reply-To: <20130805063334.GA22386@mtldesk30>
From: Eli Cohen <eli@dev.mellanox.co.il>
Date: Mon, 5 Aug 2013 09:33:34 +0300
> the intention here was to allow other module, if they so wish, to get
> notified of any problems detected at the device. I understand that you
> don't like this but is there another way to handle this requirement
> which will be accepted?
Which modules? I do not see them.
Please remove this unused facility, now.
^ permalink raw reply
* Re: [PATCH net] skge: fix build on 32 bit
From: David Miller @ 2013-08-05 6:37 UTC (permalink / raw)
To: stephen; +Cc: netdev
In-Reply-To: <20130804204034.0f96cb80@nehalam.linuxnetplumber.net>
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Sun, 4 Aug 2013 20:40:34 -0700
> The following is needed as well to fix warning/error about shifting a 32 bit
> value 32 bits which occurs if building on 32 bit platform caused by conversion
> to using dma_addr_t
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH net] net: mlx5: fix sizeof usage in health_care's reg_handler
From: Eli Cohen @ 2013-08-05 6:33 UTC (permalink / raw)
To: David Miller; +Cc: dborkman, netdev, ogerlitz
In-Reply-To: <20130802.151132.539136654627638979.davem@davemloft.net>
On Fri, Aug 02, 2013 at 03:11:32PM -0700, David Miller wrote:
> From: Daniel Borkmann <dborkman@redhat.com>
> Date: Fri, 2 Aug 2013 12:16:17 +0200
>
> > Therefore, I strongly assume sizeof(*health->health) is being meant
> > to be passed as an argument. Interestingly, there are actually no
Daniel, you're fix is correct. I meant to pass the size of the struct
and not the size of the pointer.
> > in-tree users of mlx5_[un]register_health_report_handler(), but some
> > debugging modules might want to know the correct size instead.
>
> I want these hooks and infrastructure removed immediately.
>
> If there are no in-tree users there is no reason for them to
> exist at all.
>
Hi Dave,
the intention here was to allow other module, if they so wish, to get
notified of any problems detected at the device. I understand that you
don't like this but is there another way to handle this requirement
which will be accepted?
^ permalink raw reply
* [PATCH -next] tile: fix missing unlock on error in tile_net_open()
From: Wei Yongjun @ 2013-08-05 4:42 UTC (permalink / raw)
To: cmetcalf, davem; +Cc: yongjun_wei, netdev
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Add the missing unlock before return from function tile_net_open()
in the error handling case.
Introduced by commit f3286a3af89d6db7a488f3e8f02b98d67d50f00c.
(tile: support multiple mPIPE shims in tilegx network driver)
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
drivers/net/ethernet/tile/tilegx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 907b577..5d2a719 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -1510,8 +1510,10 @@ static int tile_net_open(struct net_device *dev)
/* Get the instance info. */
rc = gxio_mpipe_link_instance(dev->name);
- if (rc < 0 || rc >= NR_MPIPE_MAX)
+ if (rc < 0 || rc >= NR_MPIPE_MAX) {
+ mutex_unlock(&tile_net_devs_for_channel_mutex);
return -EIO;
+ }
priv->instance = rc;
instance = rc;
^ permalink raw reply related
* [PATCH v4] net/phy: micrel: Add OF configuration support for ksz9021
From: Sean Cross @ 2013-08-05 4:02 UTC (permalink / raw)
To: Sascha Hauer, Duan Fugang-B38611, netdev@vger.kernel.org,
devicetree@vger.kernel.org
Cc: David Miller, stephen@networkplumber.org, Steven Rostedt,
Sean Cross
In-Reply-To: <1375675330-14220-1-git-send-email-xobs@kosagi.com>
Some boards require custom PHY configuration, for example due to trace
length differences. Add the ability to configure these registers in
order to get the PHY to function on boards that need it.
Because PHYs are auto-detected based on MDIO device IDs, allow PHY
configuration to be specified in the parent Ethernet device node if no
PHY device node is present.
Signed-off-by: Sean Cross <xobs@kosagi.com>
---
.../devicetree/bindings/net/micrel-ksz9021.txt | 19 ++++
drivers/net/phy/micrel.c | 101 +++++++++++++++++++-
2 files changed, 119 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/micrel-ksz9021.txt
diff --git a/Documentation/devicetree/bindings/net/micrel-ksz9021.txt b/Documentation/devicetree/bindings/net/micrel-ksz9021.txt
new file mode 100644
index 0000000..b3e5cd2
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/micrel-ksz9021.txt
@@ -0,0 +1,19 @@
+Micrel KSZ9021 Gigabit Ethernet PHY
+
+Some boards require special tuning values, particularly when it comes to
+clock delays. You can specify clock delay values by adding
+micrel-specific properties to an Ethernet OF device node.
+
+Optional properties:
+- micrel,clk-control-pad-skew : Timing offset for the MII clock line
+- micrel,rx-data-pad-skew : Timing offset for the RX MII pad
+- micrel,tx-data-pad-skew : Timing offset for the TX MII pad
+
+Example:
+ &enet {
+ micrel,clk-control-pad-skew = <0xf0f0>;
+ micrel,rx-data-pad-skew = <0x0000>;
+ micrel,tx-data-pad-skew = <0xffff>;
+ status = "okay";
+ };
+
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 2510435..3e60ed0 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -25,6 +25,7 @@
#include <linux/module.h>
#include <linux/phy.h>
#include <linux/micrel_phy.h>
+#include <linux/of.h>
/* Operation Mode Strap Override */
#define MII_KSZPHY_OMSO 0x16
@@ -53,6 +54,18 @@
#define KS8737_CTRL_INT_ACTIVE_HIGH (1 << 14)
#define KSZ8051_RMII_50MHZ_CLK (1 << 7)
+/* Write/read to/from extended registers */
+#define MII_KSZPHY_EXTREG 0x0b
+#define KSZPHY_EXTREG_WRITE 0x8000
+
+#define MII_KSZPHY_EXTREG_WRITE 0x0c
+#define MII_KSZPHY_EXTREG_READ 0x0d
+
+/* Extended registers */
+#define MII_KSZPHY_CLK_CONTROL_PAD_SKEW 0x104
+#define MII_KSZPHY_RX_DATA_PAD_SKEW 0x105
+#define MII_KSZPHY_TX_DATA_PAD_SKEW 0x106
+
static int ksz_config_flags(struct phy_device *phydev)
{
int regval;
@@ -65,6 +78,20 @@ static int ksz_config_flags(struct phy_device *phydev)
return 0;
}
+static int kszphy_extended_write(struct phy_device *phydev,
+ u32 regnum, u16 val)
+{
+ phy_write(phydev, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | regnum);
+ return phy_write(phydev, MII_KSZPHY_EXTREG_WRITE, val);
+}
+
+static int kszphy_extended_read(struct phy_device *phydev,
+ u32 regnum)
+{
+ phy_write(phydev, MII_KSZPHY_EXTREG, regnum);
+ return phy_read(phydev, MII_KSZPHY_EXTREG_READ);
+}
+
static int kszphy_ack_interrupt(struct phy_device *phydev)
{
/* bit[7..0] int status, which is a read and clear register. */
@@ -141,6 +168,78 @@ static int ks8051_config_init(struct phy_device *phydev)
return rc < 0 ? rc : 0;
}
+static int ksz9021_load_values_from_of(struct phy_device *phydev,
+ struct device_node *of_node, u16 reg,
+ char *field1, char *field2,
+ char *field3, char *field4)
+{
+ int val1 = -1;
+ int val2 = -2;
+ int val3 = -3;
+ int val4 = -4;
+ int newval;
+ int matches = 0;
+
+ if (!of_property_read_u32(of_node, field1, &val1))
+ matches++;
+
+ if (!of_property_read_u32(of_node, field2, &val2))
+ matches++;
+
+ if (!of_property_read_u32(of_node, field3, &val3))
+ matches++;
+
+ if (!of_property_read_u32(of_node, field4, &val4))
+ matches++;
+
+ if (!matches)
+ return 0;
+
+ if (matches < 4)
+ newval = kszphy_extended_read(phydev, reg);
+ else
+ newval = 0;
+
+ if (val1 != -1)
+ newval = ((newval & 0xfff0) | ((val1/200)&0xf) << 0);
+
+ if (val2 != -1)
+ newval = ((newval & 0xff0f) | ((val2/200)&0xf) << 4);
+
+ if (val3 != -1)
+ newval = ((newval & 0xf0ff) | ((val3/200)&0xf) << 8);
+
+ if (val4 != -1)
+ newval = ((newval & 0x0fff) | ((val4/200)&0xf) << 12);
+
+ return kszphy_extended_write(phydev, reg, newval);
+}
+
+static int ksz9021_config_init(struct phy_device *phydev)
+{
+ struct device *dev = &phydev->dev;
+ struct device_node *of_node = dev->of_node;
+
+ if (!of_node && dev->parent->of_node)
+ of_node = dev->parent->of_node;
+
+ if (of_node) {
+ ksz9021_load_values_from_of(phydev, of_node,
+ MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
+ "txen-skew", "txc-skew",
+ "rxdv-skew", "rxc-skew");
+ ksz9021_load_values_from_of(phydev, of_node,
+ MII_KSZPHY_RX_DATA_PAD_SKEW,
+ "rxd0-skew", "rxd1-skew",
+ "rxd2-skew", "rxd3-skew");
+ ksz9021_load_values_from_of(phydev, of_node,
+ MII_KSZPHY_TX_DATA_PAD_SKEW,
+ "txd0-skew", "txd1-skew",
+ "txd2-skew", "txd3-skew");
+ }
+ return 0;
+}
+
#define KSZ8873MLL_GLOBAL_CONTROL_4 0x06
#define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX (1 << 6)
#define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED (1 << 4)
@@ -281,7 +380,7 @@ static struct phy_driver ksphy_driver[] = {
.name = "Micrel KSZ9021 Gigabit PHY",
.features = (PHY_GBIT_FEATURES | SUPPORTED_Pause),
.flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
- .config_init = kszphy_config_init,
+ .config_init = ksz9021_config_init,
.config_aneg = genphy_config_aneg,
.read_status = genphy_read_status,
.ack_interrupt = kszphy_ack_interrupt,
--
1.7.9.5
^ permalink raw reply related
* [PATCH v4] Add OF bindings to Micrel ksz9021 PHY
From: Sean Cross @ 2013-08-05 4:02 UTC (permalink / raw)
To: Sascha Hauer, Duan Fugang-B38611, netdev@vger.kernel.org,
devicetree@vger.kernel.org
Cc: David Miller, stephen@networkplumber.org, Steven Rostedt,
Sean Cross
Some boards require custom parameters be passed to the Micrel PHY.
Allow these boards to specify custom timing parameters in the device
tree node.
Changes since v3:
- Add an example of parameters on an mdio bus
- Specify values in picoseconds rather than as register values
Changes since v2:
- limited the scope to just ksz9021 rather than all PHYs
Changes since v1:
- removed redefinition of registers and addresses
Sean Cross (1):
net/phy: micrel: Add OF configuration support for ksz9021
.../devicetree/bindings/net/micrel-ksz9021.txt | 19 ++++
drivers/net/phy/micrel.c | 101 +++++++++++++++++++-
2 files changed, 119 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/micrel-ksz9021.txt
--
1.7.9.5
^ permalink raw reply
* Re: [PATCH] hostap: do not return positive number on failure path in prism2_open()
From: Alexey Khoroshilov @ 2013-08-05 4:01 UTC (permalink / raw)
To: Joe Perches
Cc: Jouni Malinen, John W. Linville,
linux-wireless-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
ldv-project-tpLiQldItUH5n4uC9ZG1Ww
In-Reply-To: <1375673616.3133.23.camel@joe-AO722>
On 08/05/2013 07:33 AM, Joe Perches wrote:
> On Mon, 2013-08-05 at 07:18 +0400, Alexey Khoroshilov wrote:
>> prism2_open() as an .ndo_open handler should not return positive numbers
>> in case of failure, but it does return 1 in a couple of places.
>>
>> Found by Linux Driver Verification project (linuxtesting.org).
> How?
>
> http://linuxtesting.org/project/ldv
> http://linuxtesting.org/results/ldv
>
> Shows defects and patches to fix them, but not any script
> used to find it.
There is a link to build instructions there:
http://forge.ispras.ru/projects/ldv/wiki/Downloading_and_Building_LDV
Currently it requires some efforts to install all the dependencies, the
simplest way is to use puppet script for Ubuntu 12.04 that you can find
in the repository.
--
Alexey
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH net] skge: fix build on 32 bit
From: Stephen Hemminger @ 2013-08-05 3:40 UTC (permalink / raw)
To: David Miller; +Cc: netdev
In-Reply-To: <20130804.183553.514470399074672614.davem@davemloft.net>
The following is needed as well to fix warning/error about shifting a 32 bit
value 32 bits which occurs if building on 32 bit platform caused by conversion
to using dma_addr_t
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
--- a/drivers/net/ethernet/marvell/skge.c 2013-08-04 20:30:57.003636568 -0700
+++ b/drivers/net/ethernet/marvell/skge.c 2013-08-04 20:34:43.104589097 -0700
@@ -943,8 +943,8 @@ static int skge_rx_setup(struct skge_por
if (pci_dma_mapping_error(skge->hw->pdev, map))
return -1;
- rd->dma_lo = map;
- rd->dma_hi = map >> 32;
+ rd->dma_lo = lower_32_bits(map);
+ rd->dma_hi = upper_32_bits(map);
e->skb = skb;
rd->csum1_start = ETH_HLEN;
rd->csum2_start = ETH_HLEN;
@@ -2551,7 +2551,7 @@ static int skge_up(struct net_device *de
BUG_ON(skge->dma & 7);
- if ((u64)skge->dma >> 32 != ((u64) skge->dma + skge->mem_size) >> 32) {
+ if (upper_32_bits(skge->dma) != upper_32_bits(skge->dma + skge->mem_size)) {
dev_err(&hw->pdev->dev, "pci_alloc_consistent region crosses 4G boundary\n");
err = -EINVAL;
goto free_pci_mem;
@@ -2756,8 +2756,8 @@ static netdev_tx_t skge_xmit_frame(struc
dma_unmap_addr_set(e, mapaddr, map);
dma_unmap_len_set(e, maplen, len);
- td->dma_lo = map;
- td->dma_hi = map >> 32;
+ td->dma_lo = lower_32_bits(map);
+ td->dma_hi = upper_32_bits(map);
if (skb->ip_summed == CHECKSUM_PARTIAL) {
const int offset = skb_checksum_start_offset(skb);
@@ -2796,8 +2796,8 @@ static netdev_tx_t skge_xmit_frame(struc
tf = e->desc;
BUG_ON(tf->control & BMU_OWN);
- tf->dma_lo = map;
- tf->dma_hi = (u64) map >> 32;
+ tf->dma_lo = lower_32_bits(map);
+ tf->dma_hi = upper_32_bits(map);
dma_unmap_addr_set(e, mapaddr, map);
dma_unmap_len_set(e, maplen, skb_frag_size(frag));
^ permalink raw reply
* Re: [PATCH] hostap: do not return positive number on failure path in prism2_open()
From: Joe Perches @ 2013-08-05 3:33 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Jouni Malinen, John W. Linville,
linux-wireless-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
ldv-project-tpLiQldItUH5n4uC9ZG1Ww
In-Reply-To: <1375672708-3017-1-git-send-email-khoroshilov-ufN2psIa012HXe+LvDLADg@public.gmane.org>
On Mon, 2013-08-05 at 07:18 +0400, Alexey Khoroshilov wrote:
> prism2_open() as an .ndo_open handler should not return positive numbers
> in case of failure, but it does return 1 in a couple of places.
>
> Found by Linux Driver Verification project (linuxtesting.org).
How?
http://linuxtesting.org/project/ldv
http://linuxtesting.org/results/ldv
Shows defects and patches to fix them, but not any script
used to find it.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH] hostap: do not return positive number on failure path in prism2_open()
From: Alexey Khoroshilov @ 2013-08-05 3:18 UTC (permalink / raw)
To: Jouni Malinen, John W. Linville
Cc: Alexey Khoroshilov, linux-wireless, netdev, linux-kernel,
ldv-project
prism2_open() as an .ndo_open handler should not return positive numbers
in case of failure, but it does return 1 in a couple of places.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/net/wireless/hostap/hostap_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 15f0fad..e4f56ad 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -667,7 +667,7 @@ static int prism2_open(struct net_device *dev)
if (local->no_pri) {
printk(KERN_DEBUG "%s: could not set interface UP - no PRI "
"f/w\n", dev->name);
- return 1;
+ return -ENODEV;
}
if ((local->func->card_present && !local->func->card_present(local)) ||
@@ -682,7 +682,7 @@ static int prism2_open(struct net_device *dev)
printk(KERN_WARNING "%s: could not enable MAC port\n",
dev->name);
prism2_close(dev);
- return 1;
+ return -ENODEV;
}
if (!local->dev_enabled)
prism2_callback(local, PRISM2_CALLBACK_ENABLE);
--
1.8.1.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