Netdev List
 help / color / mirror / Atom feed
* Re: [RFC virtio-next 0/4] Introduce CAIF Virtio and reversed Vrings
From: Rusty Russell @ 2012-11-01  7:41 UTC (permalink / raw)
  To: Sjur Brændeland
  Cc: Michael S. Tsirkin, netdev, Linus Walleij, dmitry.tarnyagin,
	linux-kernel, virtualization, sjur
In-Reply-To: <1351723614-4145-1-git-send-email-sjur@brendeland.net>

Sjur Brændeland <sjur@brendeland.net> writes:
> Zero-Copy data transport on the modem is primary goal for CAIF Virtio.
> In order to achieve Zero-Copy the direction of the Virtio rings are
> flipped in the RX direction. So we have implemented the Virtio
> access-function similar to what is found in vhost.c.

So, this adds another host-side virtqueue implementation.

Can we combine them together conveniently?  You pulled out more stuff
into vring.h which is a start, but it's a bit overloaded.

Perhaps we should separate the common fields into struct vring, and use
it to build:

        struct vring_guest {
                struct vring vr;
                u16 last_used_idx;
        };

        struct vring_host {
                struct vring vr;
                u16 last_avail_idx;
        };

I haven't looked closely at vhost to see what it wants, but I would
think we could share more code.

Cheers,
Rusty.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* Re: [PATCH 4/4] arm/dts: am33xx: Add CPSW and MDIO module nodes for AM33XX
From: Richard Cochran @ 2012-11-01  7:45 UTC (permalink / raw)
  To: Benoit Cousson
  Cc: Vaibhav Hiremath, netdev, paul, linux-arm-kernel, linux-omap,
	Mugunthan V N
In-Reply-To: <50914107.2090909@ti.com>

On Wed, Oct 31, 2012 at 04:17:27PM +0100, Benoit Cousson wrote:
> > +			compatible = "ti,cpsw";
> > +			ti,hwmods = "cpgmac0";
> > +			cpdma_channels = <8>;
> > +			host_port_no = <0>;
> > +			cpdma_reg_ofs = <0x800>;
> > +			cpdma_sram_ofs = <0xa00>;
> > +			ale_reg_ofs = <0xd00>;
> > +			ale_entries = <1024>;
> > +			host_port_reg_ofs = <0x108>;
> > +			hw_stats_reg_ofs = <0x900>;
> > +			bd_ram_ofs = <0x2000>;
> > +			bd_ram_size = <0x2000>;
> > +			no_bd_ram = <0>;
> > +			rx_descs = <64>;
> > +			mac_control = <0x20>;
> 
> Do you have to store all these data in the DTS? Cannot it be in the driver?
> 
> Do you expect to have several instance of the same IP with different
> parameters here?

As I understand it, there are only two different layouts for the CPSW,
the one in the dm814x and the one in the am335x. So I think it would
work to put only the version register offet in the DT, and the let the
driver figure out the rest from there.

But if TI is planning on reordering the registers with each new
silicon revision, again and again, then it might make sense to keep
the offsets in the DT.

[ I really wonder why the hardware people think that reshuffling the
  register layout constitutes an improvement. ]

Thanks,
Richard

^ permalink raw reply

* Re: [PATCH net-next 0/3] Enable PPS and PTP clocks automatically
From: Richard Cochran @ 2012-11-01  8:19 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: David Miller, Rodolfo Giometti, netdev, linux-net-drivers
In-Reply-To: <1351733397.2706.62.camel@bwh-desktop.uk.solarflarecom.com>

Ben,

I really like this idea, but I have a couple of questions, below.

On Thu, Nov 01, 2012 at 01:29:57AM +0000, Ben Hutchings wrote:

> Ben Hutchings (3):
>   pps, ptp: Remove dependencies on EXPERIMENTAL

Kees Cook just posted a massive series to remove EXPERIMENTAL
everywhere. Maybe it would make sense to have this series follow that
one?

>   ptp: Make PTP_1588_CLOCK select rather than depend on PPS
>   ptp: Enable clock drivers along with associated net/PHY drivers
> 
>  drivers/net/ethernet/intel/Kconfig                 |   28 +------------------
>  drivers/net/ethernet/intel/igb/Makefile            |    4 +--
>  drivers/net/ethernet/intel/igb/igb.h               |    6 ----
>  drivers/net/ethernet/intel/igb/igb_ethtool.c       |    2 -
>  drivers/net/ethernet/intel/igb/igb_main.c          |   28 --------------------

The #ifdefs in the Intel and PCH drivers are meant to streamline the
code for users who are not interested in time stamping. Although the
overhead of the additional is minimal (it really just a bunch of
tests), and I wouldn't mind removing the conditionals, I suspect that
some people won't like it.

>  drivers/net/ethernet/intel/ixgbe/Makefile          |    3 +-
>  drivers/net/ethernet/intel/ixgbe/ixgbe.h           |    6 ----
>  drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c   |    2 -
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c      |   28 --------------------
>  drivers/net/ethernet/oki-semi/pch_gbe/Kconfig      |   16 -----------
>  drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h    |    2 -
>  .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   |   14 ----------

Thanks,
Richard

^ permalink raw reply

* [net] ixgbe: PTP get_ts_info missing software support
From: Jeff Kirsher @ 2012-11-01  8:30 UTC (permalink / raw)
  To: davem; +Cc: Jacob Keller, netdev, gospo, sassmann, stable, Jeff Kirsher

From: Jacob Keller <jacob.e.keller@intel.com>

This patch corrects the ethtool get_ts_info functon which did not state that
software timestamping was supported, even though it is.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
CC: Stable <stable@vger.kernel.org> [3.5]
Tested-by: Stephen Ko <stephen.s.ko@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 56b20d1..116f0e9 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -2673,6 +2673,9 @@ static int ixgbe_get_ts_info(struct net_device *dev,
 	case ixgbe_mac_X540:
 	case ixgbe_mac_82599EB:
 		info->so_timestamping =
+			SOF_TIMESTAMPING_TX_SOFTWARE |
+			SOF_TIMESTAMPING_RX_SOFTWARE |
+			SOF_TIMESTAMPING_SOFTWARE |
 			SOF_TIMESTAMPING_TX_HARDWARE |
 			SOF_TIMESTAMPING_RX_HARDWARE |
 			SOF_TIMESTAMPING_RAW_HARDWARE;
-- 
1.7.11.7

^ permalink raw reply related

* Re: [uclinux-dist-devel] [PATCH RFC net-next 2/4] bfin_mac: replace sys time stamps with raw ones instead.
From: Richard Cochran @ 2012-11-01  8:41 UTC (permalink / raw)
  To: Bob Liu
  Cc: netdev, Miroslav Lichvar, John Ronciak, John Stultz, Jeff Kirsher,
	device-drivers-devel, Jacob Keller, uclinux-dist-devel,
	Patrick Ohly, David Miller
In-Reply-To: <CAA_GA1eLXajk+wfwf7QYVoabDDeXLZecaTFX+6JRyoaYOyztQQ@mail.gmail.com>

On Thu, Nov 01, 2012 at 10:08:01AM +0800, Bob Liu wrote:
> How to use it?
 
ptp4l -i eth0 -q -v     # master
ptp4l -i eth0 -q -v -s  # slave

#
# Wait for state s2 on the slave_________
#                                        \
ptp4l[336.203]: master offset        569 s2 adj +102784 path delay 33666
#
# Then start phc2sys.
#

phc2sys -s /dev/ptp0

> But this can't work.

Can you post the output of the ptp4l and phc2sys on the slave?

Thanks again for testing this for me,
Richard

^ permalink raw reply

* Re: [uclinux-dist-devel] [PATCH RFC net-next 2/4] bfin_mac: replace sys time stamps with raw ones instead.
From: Bob Liu @ 2012-11-01  8:54 UTC (permalink / raw)
  To: Richard Cochran
  Cc: netdev, Miroslav Lichvar, John Ronciak, John Stultz, Jeff Kirsher,
	device-drivers-devel, Jacob Keller, uclinux-dist-devel,
	Patrick Ohly, David Miller
In-Reply-To: <20121101084111.GC2637@netboy.at.omicron.at>

On Thu, Nov 1, 2012 at 4:41 PM, Richard Cochran
<richardcochran@gmail.com> wrote:
> On Thu, Nov 01, 2012 at 10:08:01AM +0800, Bob Liu wrote:
>> How to use it?
>
> ptp4l -i eth0 -q -v     # master
> ptp4l -i eth0 -q -v -s  # slave
>
> #
> # Wait for state s2 on the slave_________
> #                                        \
> ptp4l[336.203]: master offset        569 s2 adj +102784 path delay 33666
> #
> # Then start phc2sys.
> #
>
> phc2sys -s /dev/ptp0
>
>> But this can't work.
>
> Can you post the output of the ptp4l and phc2sys on the slave?
>

I opened three consoles on slave machine using telnet:
console 1:
root:~> ptp4l -i eth0 -q -v -s
ptp4l[75.904]: selected /dev/ptp0 as PTP clock
ptp4l[75.908]: m
ptp4l[75.908]: driver rejected most general HWTSTAMP filter
ptp4l[75.908]: port 1: INITIALIZING to LISTENING on INITIALIZE
ptp4l[75.912]: port 0: INITIALIZING to LISTENING on INITIALIZE
ptp4l[76.244]: port 1: new foreign master 00e022.fffe.fe8529-1
ptp4l[80.252]: selected best master clock 00e022.fffe.fe8529
ptp4l[80.252]: port 1: LISTENING to UNCALIBRATED on RS_SLAVE
ptp4l[81.288]: master offset -17688624512 s0 adj      +0 path delay       7456
ptp4l[82.292]: master offset -17688618592 s0 adj      +0 path delay       7456
ptp4l[83.296]: master offset -17688613232 s0 adj      +0 path delay       7584
ptp4l[84.300]: master offset -17688607696 s1 adj      +0 path delay       7584
ptp4l[85.304]: master offset       4736 s2 adj   +4736 path delay
 7584
ptp4l[85.308]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED
ptp4l[86.308]: master offset       5600 s2 adj   +7021 path delay       7584
ptp4l[87.312]: master offset       2582 s2 adj   +5683 path delay       9066
ptp4l[88.316]: master offset       2370 s2 adj   +6245 path delay       9262
ptp4l[89.320]: master offset       1568 s2 adj   +6154 path delay       9424
ptp4l[90.324]: master offset        880 s2 adj   +5937 path delay       9424
ptp4l[91.328]: master offset        680 s2 adj   +6001 path delay       9512
ptp4l[92.332]: master offset        165 s2 adj   +5690 path delay       9595
ptp4l[93.336]: master offset        -59 s2 adj   +5515 path delay       9595
ptp4l[94.340]: master offset        -12 s2 adj   +5545 path delay       9644
ptp4l[95.344]: master offset        -95 s2 adj   +5458 path delay       9679
ptp4l[96.348]: master offset         49 s2 adj   +5574 path delay       9679
ptp4l[97.352]: master offset       -143 s2 adj   +5396 path delay       9935


After see s2 state, i start phc2sys in console 2:
root:~> phc2sys -s /dev/ptp0
phc   3421792 s1 46.828595280 drift 0.00
phc   3430512 s2 47.832595280 drift 0.00
phc   3436256 s3 48.836595280 drift 0.00
phc   3454080 s4 49.840595280 drift 10719.79
phc    -37919 s4 50.841130481 drift -655.91
phc     10983 s4 51.845157639 drift 2638.99
phc      7277 s4 52.849147421 drift 4822.09
phc     12694 s4 53.853137462 drift 8630.29
phc     -6028 s4 54.857119908 drift 6821.89
phc     -7998 s4 55.861117234 drift 4422.49
phc     -2657 s4 56.865118399 drift 3625.39
phc     -5072 s4 57.869116640 drift 2103.79
phc     23391 s4 58.873118079 drift 9121.09
phc     -8035 s4 59.877092589 drift 6710.59
phc    -68278 s4 60.881091402 drift -13772.81
phc     53773 s4 61.881152717 drift 2359.09
phc     25317 s4 62.885112965 drift 9954.19
phc     19080 s4 63.889085128 drift 15678.19
phc     -6000 s4 64.893055984 drift 13878.19
phc    -17746 s4 65.897046190 drift 8554.39
phc    -13533 s4 66.901050019 drift 4494.49
phc     14260 s4 67.905055012 drift 8772.49
phc     -7786 s4 68.909036278 drift 6436.69


Then in console 3:
root:~> date
Thu Jan  1 00:00:58 UTC 1970
root:~> date
Thu Jan  1 00:00:59 UTC 1970
root:~> date
Thu Jan  1 00:00:59 UTC 1970
root:~> date
Thu Jan  1 00:01:01 UTC 1970
root:~> date
Thu Jan  1 00:01:01 UTC 1970
root:~> date
Thu Jan  1 00:01:14 UTC 1970

date in master side is:
root:/> date
Thu Dec 21 01:34:26 UTC 2006
root:/>

So the system time didn't sync.

-- 
Thanks,
--Bob

^ permalink raw reply

* Re: [PATCH 3/9] net: xfrm: use this_cpu_ptr per-cpu helper
From: Shan Wei @ 2012-11-01  8:56 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: steffen.klassert, David Miller, NetDev, Herbert Xu,
	Kernel-Maillist
In-Reply-To: <0000013ab7e4a640-60bd5b38-a1fc-4730-b918-4109211ffea0-000000@email.amazonses.com>

Christoph Lameter said, at 2012/11/1 1:35:
> It would be better to use
> 
> 	this_cpu_read(tfms)
> 
> since that would also make it atomic vs interrupts. The above code (both
> original and modified) could determine a pointer to a per cpu structure
> and then take an interrupt which would move the task. On return we would
> be accessing the per cpu variable of another processor.

this_cpu_read
|-----_this_cpu_generic_read

#define _this_cpu_generic_read(pcp)                                     \
({      typeof(pcp) ret__;                                              \
        preempt_disable();                                              \
        ret__ = *this_cpu_ptr(&(pcp));                                  \
        preempt_enable();                                               \
        ret__;                                                          \
})


this_cpu_read operations locate per-cpu variable with preemption safe, not
disable interrupts. why is it atomic vs interrupts?

I have no idea whether we need to disable preemption for this code?
At least, xfrm code run well with per_cpu_ptr which don't disable preemption.

^ permalink raw reply

* Re: [PATCH 3/9] net: xfrm: use this_cpu_ptr per-cpu helper
From: Shan Wei @ 2012-11-01  9:00 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Christoph Lameter, steffen.klassert, David Miller, NetDev,
	Kernel-Maillist
In-Reply-To: <20121101034136.GA27343@gondor.apana.org.au>

Herbert Xu said, at 2012/11/1 11:41:
> Please refer to the comment in the patch above.
> 
> But I think the patch is wrong anyway because it would introduce
> a warning, no?

yes, __this_cpu_ptr(or __this_cpu_read) is more reasonable 
which don't check preemption context.

> 
> Thanks,
> 

^ permalink raw reply

* Re: [Suggestion] net-ipv6: format %8s change to %16s in rt6_info_route function of route.c
From: Eric Dumazet @ 2012-11-01  9:01 UTC (permalink / raw)
  To: Chen Gang; +Cc: linux-kernel@vger.kernel.org, netdev
In-Reply-To: <50921A92.8000809@asianux.com>

On Thu, 2012-11-01 at 14:45 +0800, Chen Gang wrote:
> Hello:
> 
> 1) For Public Kernel:
> 
>    A) in rt6_info_route function of net/ipv6/route.c
> 
>    B) the length of rt->rt6i_dev->name is 16 (IFNAMSIZ)
> 
>    C) using %16s is better than %8s (it will be more "beautiful")
>       (also suggest to delete RT6_INFO_LEN, it is useless for ever)
> 
> 
> 
> 2) For Red Hat RHEL5:
> 
>    A) in rt6_info_route function of net/ipv6/route.c
> 
>    B) the length of rt->rt6i_dev->name is 16 (IFNAMSIZ)
> 
>    C) for RT6_INFO_LEN is still useful, so it is an correctness issue.
> 
>    the relative patch for RHEL5 is below:

Hi Chen

Thats a good suggestion indeed.

Networking patches should be sent to netdev@vger.kernel.org (added in
CC)

This list only cares about recent generic kernels, not RedHat ones.

If you want to provide a patch, please base it on David Miller net-next
[1] tree, and make it official (read Documentation/SubmittingPatches for
general advices)

By the way, the %8s should be replaced by %s, there is no need to make
/proc/net/ipv6_route 'beautiful'. In the past, it was *needed* because
each line had to be of a given length, but its not anymore the case.

Thanks

[1] :
http://git.kernel.org/?p=linux/kernel/git/davem/net-next.git;a=summary

^ permalink raw reply

* Who's run a background check on you? DUI's, Tickets, Criminal Records.
From: michael963fleming @ 2012-11-01  9:21 UTC (permalink / raw)
  To: avmgkt

Guess what my background search pulled up! http://bit.ly/Q7WH86

^ permalink raw reply

* Re: [PATCH 3/9] net: xfrm: use this_cpu_ptr per-cpu helper
From: Steffen Klassert @ 2012-11-01  9:18 UTC (permalink / raw)
  To: Shan Wei
  Cc: Christoph Lameter, David Miller, NetDev, Herbert Xu,
	Kernel-Maillist
In-Reply-To: <50923956.5090206@gmail.com>

On Thu, Nov 01, 2012 at 04:56:54PM +0800, Shan Wei wrote:
> Christoph Lameter said, at 2012/11/1 1:35:
> > It would be better to use
> > 
> > 	this_cpu_read(tfms)
> > 
> > since that would also make it atomic vs interrupts. The above code (both
> > original and modified) could determine a pointer to a per cpu structure
> > and then take an interrupt which would move the task. On return we would
> > be accessing the per cpu variable of another processor.
> 
> this_cpu_read
> |-----_this_cpu_generic_read
> 
> #define _this_cpu_generic_read(pcp)                                     \
> ({      typeof(pcp) ret__;                                              \
>         preempt_disable();                                              \
>         ret__ = *this_cpu_ptr(&(pcp));                                  \
>         preempt_enable();                                               \
>         ret__;                                                          \
> })
> 
> 
> this_cpu_read operations locate per-cpu variable with preemption safe, not
> disable interrupts. why is it atomic vs interrupts?
> 
> I have no idea whether we need to disable preemption for this code?
> At least, xfrm code run well with per_cpu_ptr which don't disable preemption.

We compare the name of the newly allocated crypto transform against the
existing ones. The name is the same on every percpu transform and it
does not change after the transform is allocated. So we don't care
if we get migrated or not, we can just take the transform from an
arbitrary cpu to read the name from it.

^ permalink raw reply

* Re: [PATCH 4/4] arm/dts: am33xx: Add CPSW and MDIO module nodes for AM33XX
From: Cousson, Benoit @ 2012-11-01  9:28 UTC (permalink / raw)
  To: Richard Cochran
  Cc: Vaibhav Hiremath, netdev, paul, linux-arm-kernel, linux-omap,
	Mugunthan V N
In-Reply-To: <20121101074508.GA2637@netboy.at.omicron.at>

On 11/1/2012 8:45 AM, Richard Cochran wrote:
> On Wed, Oct 31, 2012 at 04:17:27PM +0100, Benoit Cousson wrote:
>>> +			compatible = "ti,cpsw";
>>> +			ti,hwmods = "cpgmac0";
>>> +			cpdma_channels = <8>;
>>> +			host_port_no = <0>;
>>> +			cpdma_reg_ofs = <0x800>;
>>> +			cpdma_sram_ofs = <0xa00>;
>>> +			ale_reg_ofs = <0xd00>;
>>> +			ale_entries = <1024>;
>>> +			host_port_reg_ofs = <0x108>;
>>> +			hw_stats_reg_ofs = <0x900>;
>>> +			bd_ram_ofs = <0x2000>;
>>> +			bd_ram_size = <0x2000>;
>>> +			no_bd_ram = <0>;
>>> +			rx_descs = <64>;
>>> +			mac_control = <0x20>;
>>
>> Do you have to store all these data in the DTS? Cannot it be in the driver?
>>
>> Do you expect to have several instance of the same IP with different
>> parameters here?
>
> As I understand it, there are only two different layouts for the CPSW,
> the one in the dm814x and the one in the am335x. So I think it would
> work to put only the version register offet in the DT, and the let the
> driver figure out the rest from there.

Yes, that's indeed better. We did that for other IPs already (GPIO, I2C...)

> But if TI is planning on reordering the registers with each new
> silicon revision, again and again, then it might make sense to keep
> the offsets in the DT.

Yeah, let's assume they will do a better job in the future.

All these offset registers information does belong to the driver, and 
even if the HW change a lot, I still rather hide that in the driver.
It will always be cleaner, most efficient, and will reduce the size if 
the blob.

> [ I really wonder why the hardware people think that reshuffling the
>    register layout constitutes an improvement. ]

I've been wondering that for ten years :-(
I'm always hoping it will be better some day.

Regards,
Benoit

^ permalink raw reply

* Re: [uclinux-dist-devel] [PATCH RFC net-next 2/4] bfin_mac: replace sys time stamps with raw ones instead.
From: Richard Cochran @ 2012-11-01  9:35 UTC (permalink / raw)
  To: Bob Liu
  Cc: netdev, Miroslav Lichvar, John Ronciak, John Stultz, Jeff Kirsher,
	device-drivers-devel, Jacob Keller, uclinux-dist-devel,
	Patrick Ohly, David Miller
In-Reply-To: <CAA_GA1f=2ubb1z6rr1L8TR54cwh1NQcKiiaZqqv2r3mjX1wL7g@mail.gmail.com>

On Thu, Nov 01, 2012 at 04:54:30PM +0800, Bob Liu wrote:
> 
> date in master side is:
> root:/> date
> Thu Dec 21 01:34:26 UTC 2006
> root:/>

What is the time on the master from the 'testptp -g' command?
 
> So the system time didn't sync.

I guess that you need to set the PHC time on the master, using 'testptp -s'.

[ There are always two clocks on each host, the Linux system time and
  the PHC time in the hardware clock. ]

Thanks,
Richard

^ permalink raw reply

* Re: [PATCH RFC net-next 2/4] bfin_mac: replace sys time stamps with raw ones instead.
From: Bob Liu @ 2012-11-01  9:39 UTC (permalink / raw)
  To: Richard Cochran
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Miroslav Lichvar, John Ronciak,
	John Stultz, Jeff Kirsher,
	device-drivers-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	Jacob Keller, uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	Patrick Ohly, David Miller
In-Reply-To: <20121101093540.GB5949-TJb37gCd1q6chkuNt9O67llkmcu1nq/N@public.gmane.org>

On Thu, Nov 1, 2012 at 5:35 PM, Richard Cochran
<richardcochran-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On Thu, Nov 01, 2012 at 04:54:30PM +0800, Bob Liu wrote:
>>
>> date in master side is:
>> root:/> date
>> Thu Dec 21 01:34:26 UTC 2006
>> root:/>
>
> What is the time on the master from the 'testptp -g' command?
>
>> So the system time didn't sync.
>
> I guess that you need to set the PHC time on the master, using 'testptp -s'.
>
> [ There are always two clocks on each host, the Linux system time and
>   the PHC time in the hardware clock. ]
>

Thank you very much.
It works.

-- 
Regards,
--Bob

^ permalink raw reply

* Re: [PATCH V2 net-next 1/4] bfin_mac: only advertise hardware time stamped when enabled.
From: Bob Liu @ 2012-11-01  9:40 UTC (permalink / raw)
  To: Richard Cochran
  Cc: netdev, device-drivers-devel, uclinux-dist-devel, David Miller,
	Jacob Keller, Jeff Kirsher, John Ronciak, John Stultz,
	Mike Frysinger, Sonic Zhang
In-Reply-To: <e9f363ffac9c59b5174b4bf89a157e0dfeb151bb.1351696541.git.richardcochran@gmail.com>

On Thu, Nov 1, 2012 at 12:27 AM, Richard Cochran
<richardcochran@gmail.com> wrote:
> The hardware time stamping code is a compile time option for the blackfin.
> When it is not enabled, the driver should fall back to the standard
> ethtool reply to the get_ts_info query.
>
> Compile tested only.
>
> Signed-off-by: Richard Cochran <richardcochran@gmail.com>

Tested-by: Bob Liu <lliubbo@gmail.com>

> ---
>  drivers/net/ethernet/adi/bfin_mac.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
> index f816426..2349abb 100644
> --- a/drivers/net/ethernet/adi/bfin_mac.c
> +++ b/drivers/net/ethernet/adi/bfin_mac.c
> @@ -548,6 +548,7 @@ static int bfin_mac_ethtool_setwol(struct net_device *dev,
>         return 0;
>  }
>
> +#ifdef CONFIG_BFIN_MAC_USE_HWSTAMP
>  static int bfin_mac_ethtool_get_ts_info(struct net_device *dev,
>         struct ethtool_ts_info *info)
>  {
> @@ -566,6 +567,7 @@ static int bfin_mac_ethtool_get_ts_info(struct net_device *dev,
>                 (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT);
>         return 0;
>  }
> +#endif
>
>  static const struct ethtool_ops bfin_mac_ethtool_ops = {
>         .get_settings = bfin_mac_ethtool_getsettings,
> @@ -574,7 +576,9 @@ static const struct ethtool_ops bfin_mac_ethtool_ops = {
>         .get_drvinfo = bfin_mac_ethtool_getdrvinfo,
>         .get_wol = bfin_mac_ethtool_getwol,
>         .set_wol = bfin_mac_ethtool_setwol,
> +#ifdef CONFIG_BFIN_MAC_USE_HWSTAMP
>         .get_ts_info = bfin_mac_ethtool_get_ts_info,
> +#endif
>  };
>
>  /**************************************************************************/
> --
> 1.7.2.5
>

-- 
Regards,
--Bob

^ permalink raw reply

* Re: [PATCH V2 net-next 3/4] bfin_mac: offer a PTP Hardware Clock.
From: Bob Liu @ 2012-11-01  9:40 UTC (permalink / raw)
  To: Richard Cochran
  Cc: netdev, device-drivers-devel, uclinux-dist-devel, David Miller,
	Jacob Keller, Jeff Kirsher, John Ronciak, John Stultz,
	Mike Frysinger, Sonic Zhang
In-Reply-To: <6525f9eba3712d3c11744f061b022cc4038d260f.1351696541.git.richardcochran@gmail.com>

On Thu, Nov 1, 2012 at 12:27 AM, Richard Cochran
<richardcochran@gmail.com> wrote:
> The BF518 has a PTP time unit that works in a similar way to other MAC
> based clocks, like gianfar, ixp46x, and igb. This patch adds support for
> using the blackfin as a PHC. Although the blackfin hardware does offer a
> few ancillary features, this patch implements only the basic operations.
>
> Compile tested only.
>
> Signed-off-by: Richard Cochran <richardcochran@gmail.com>

Tested-by: Bob Liu <lliubbo@gmail.com>

> ---
>  drivers/net/ethernet/adi/Kconfig    |    2 +-
>  drivers/net/ethernet/adi/bfin_mac.c |  170 ++++++++++++++++++++++++++++++++++-
>  drivers/net/ethernet/adi/bfin_mac.h |    6 ++
>  3 files changed, 175 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/adi/Kconfig b/drivers/net/ethernet/adi/Kconfig
> index 49a30d3..175c38c 100644
> --- a/drivers/net/ethernet/adi/Kconfig
> +++ b/drivers/net/ethernet/adi/Kconfig
> @@ -61,7 +61,7 @@ config BFIN_RX_DESC_NUM
>
>  config BFIN_MAC_USE_HWSTAMP
>         bool "Use IEEE 1588 hwstamp"
> -       depends on BFIN_MAC && BF518
> +       depends on BFIN_MAC && BF518 && PTP_1588_CLOCK && !(BFIN_MAC=y && PTP_1588_CLOCK=m)
>         default y
>         ---help---
>           To support the IEEE 1588 Precision Time Protocol (PTP), select y here
> diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
> index 885fa80..f1c458d 100644
> --- a/drivers/net/ethernet/adi/bfin_mac.c
> +++ b/drivers/net/ethernet/adi/bfin_mac.c
> @@ -552,11 +552,13 @@ static int bfin_mac_ethtool_setwol(struct net_device *dev,
>  static int bfin_mac_ethtool_get_ts_info(struct net_device *dev,
>         struct ethtool_ts_info *info)
>  {
> +       struct bfin_mac_local *lp = netdev_priv(dev);
> +
>         info->so_timestamping =
>                 SOF_TIMESTAMPING_TX_HARDWARE |
>                 SOF_TIMESTAMPING_RX_HARDWARE |
>                 SOF_TIMESTAMPING_RAW_HARDWARE;
> -       info->phc_index = -1;
> +       info->phc_index = lp->phc_index;
>         info->tx_types =
>                 (1 << HWTSTAMP_TX_OFF) |
>                 (1 << HWTSTAMP_TX_ON);
> @@ -887,7 +889,7 @@ static void bfin_rx_hwtstamp(struct net_device *netdev, struct sk_buff *skb)
>  static void bfin_mac_hwtstamp_init(struct net_device *netdev)
>  {
>         struct bfin_mac_local *lp = netdev_priv(netdev);
> -       u64 addend;
> +       u64 addend, ppb;
>         u32 input_clk, phc_clk;
>
>         /* Initialize hardware timer */
> @@ -898,18 +900,175 @@ static void bfin_mac_hwtstamp_init(struct net_device *netdev)
>         bfin_write_EMAC_PTP_ADDEND((u32)addend);
>
>         lp->addend = addend;
> +       ppb = 1000000000ULL * input_clk;
> +       do_div(ppb, phc_clk);
> +       lp->max_ppb = ppb - 1000000000ULL - 1ULL;
>
>         /* Initialize hwstamp config */
>         lp->stamp_cfg.rx_filter = HWTSTAMP_FILTER_NONE;
>         lp->stamp_cfg.tx_type = HWTSTAMP_TX_OFF;
>  }
>
> +static u64 bfin_ptp_time_read(struct bfin_mac_local *lp)
> +{
> +       u64 ns;
> +       u32 lo, hi;
> +
> +       lo = bfin_read_EMAC_PTP_TIMELO();
> +       hi = bfin_read_EMAC_PTP_TIMEHI();
> +
> +       ns = ((u64) hi) << 32;
> +       ns |= lo;
> +       ns <<= lp->shift;
> +
> +       return ns;
> +}
> +
> +static void bfin_ptp_time_write(struct bfin_mac_local *lp, u64 ns)
> +{
> +       u32 hi, lo;
> +
> +       ns >>= lp->shift;
> +       hi = ns >> 32;
> +       lo = ns & 0xffffffff;
> +
> +       bfin_write_EMAC_PTP_TIMELO(lo);
> +       bfin_write_EMAC_PTP_TIMEHI(hi);
> +}
> +
> +/* PTP Hardware Clock operations */
> +
> +static int bfin_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
> +{
> +       u64 adj;
> +       u32 diff, addend;
> +       int neg_adj = 0;
> +       struct bfin_mac_local *lp =
> +               container_of(ptp, struct bfin_mac_local, caps);
> +
> +       if (ppb < 0) {
> +               neg_adj = 1;
> +               ppb = -ppb;
> +       }
> +       addend = lp->addend;
> +       adj = addend;
> +       adj *= ppb;
> +       diff = div_u64(adj, 1000000000ULL);
> +
> +       addend = neg_adj ? addend - diff : addend + diff;
> +
> +       bfin_write_EMAC_PTP_ADDEND(addend);
> +
> +       return 0;
> +}
> +
> +static int bfin_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
> +{
> +       s64 now;
> +       unsigned long flags;
> +       struct bfin_mac_local *lp =
> +               container_of(ptp, struct bfin_mac_local, caps);
> +
> +       spin_lock_irqsave(&lp->phc_lock, flags);
> +
> +       now = bfin_ptp_time_read(lp);
> +       now += delta;
> +       bfin_ptp_time_write(lp, now);
> +
> +       spin_unlock_irqrestore(&lp->phc_lock, flags);
> +
> +       return 0;
> +}
> +
> +static int bfin_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
> +{
> +       u64 ns;
> +       u32 remainder;
> +       unsigned long flags;
> +       struct bfin_mac_local *lp =
> +               container_of(ptp, struct bfin_mac_local, caps);
> +
> +       spin_lock_irqsave(&lp->phc_lock, flags);
> +
> +       ns = bfin_ptp_time_read(lp);
> +
> +       spin_unlock_irqrestore(&lp->phc_lock, flags);
> +
> +       ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
> +       ts->tv_nsec = remainder;
> +       return 0;
> +}
> +
> +static int bfin_ptp_settime(struct ptp_clock_info *ptp,
> +                          const struct timespec *ts)
> +{
> +       u64 ns;
> +       unsigned long flags;
> +       struct bfin_mac_local *lp =
> +               container_of(ptp, struct bfin_mac_local, caps);
> +
> +       ns = ts->tv_sec * 1000000000ULL;
> +       ns += ts->tv_nsec;
> +
> +       spin_lock_irqsave(&lp->phc_lock, flags);
> +
> +       bfin_ptp_time_write(lp, ns);
> +
> +       spin_unlock_irqrestore(&lp->phc_lock, flags);
> +
> +       return 0;
> +}
> +
> +static int bfin_ptp_enable(struct ptp_clock_info *ptp,
> +                         struct ptp_clock_request *rq, int on)
> +{
> +       return -EOPNOTSUPP;
> +}
> +
> +static struct ptp_clock_info bfin_ptp_caps = {
> +       .owner          = THIS_MODULE,
> +       .name           = "BF518 clock",
> +       .max_adj        = 0,
> +       .n_alarm        = 0,
> +       .n_ext_ts       = 0,
> +       .n_per_out      = 0,
> +       .pps            = 0,
> +       .adjfreq        = bfin_ptp_adjfreq,
> +       .adjtime        = bfin_ptp_adjtime,
> +       .gettime        = bfin_ptp_gettime,
> +       .settime        = bfin_ptp_settime,
> +       .enable         = bfin_ptp_enable,
> +};
> +
> +static int bfin_phc_init(struct net_device *netdev, struct device *dev)
> +{
> +       struct bfin_mac_local *lp = netdev_priv(netdev);
> +
> +       lp->caps = bfin_ptp_caps;
> +       lp->caps.max_adj = lp->max_ppb;
> +       lp->clock = ptp_clock_register(&lp->caps, dev);
> +       if (IS_ERR(lp->clock))
> +               return PTR_ERR(lp->clock);
> +
> +       lp->phc_index = ptp_clock_index(lp->clock);
> +       spin_lock_init(&lp->phc_lock);
> +
> +       return 0;
> +}
> +
> +static void bfin_phc_release(struct bfin_mac_local *lp)
> +{
> +       ptp_clock_unregister(lp->clock);
> +}
> +
>  #else
>  # define bfin_mac_hwtstamp_is_none(cfg) 0
>  # define bfin_mac_hwtstamp_init(dev)
>  # define bfin_mac_hwtstamp_ioctl(dev, ifr, cmd) (-EOPNOTSUPP)
>  # define bfin_rx_hwtstamp(dev, skb)
>  # define bfin_tx_hwtstamp(dev, skb)
> +# define bfin_phc_init(netdev, dev) 0
> +# define bfin_phc_release(lp)
>  #endif
>
>  static inline void _tx_reclaim_skb(void)
> @@ -1544,12 +1703,17 @@ static int __devinit bfin_mac_probe(struct platform_device *pdev)
>         }
>
>         bfin_mac_hwtstamp_init(ndev);
> +       if (bfin_phc_init(ndev, &pdev->dev)) {
> +               dev_err(&pdev->dev, "Cannot register PHC device!\n");
> +               goto out_err_phc;
> +       }
>
>         /* now, print out the card info, in a short format.. */
>         netdev_info(ndev, "%s, Version %s\n", DRV_DESC, DRV_VERSION);
>
>         return 0;
>
> +out_err_phc:
>  out_err_reg_ndev:
>         free_irq(IRQ_MAC_RX, ndev);
>  out_err_request_irq:
> @@ -1568,6 +1732,8 @@ static int __devexit bfin_mac_remove(struct platform_device *pdev)
>         struct net_device *ndev = platform_get_drvdata(pdev);
>         struct bfin_mac_local *lp = netdev_priv(ndev);
>
> +       bfin_phc_release(lp);
> +
>         platform_set_drvdata(pdev, NULL);
>
>         lp->mii_bus->priv = NULL;
> diff --git a/drivers/net/ethernet/adi/bfin_mac.h b/drivers/net/ethernet/adi/bfin_mac.h
> index 57f042c..7a07ee0 100644
> --- a/drivers/net/ethernet/adi/bfin_mac.h
> +++ b/drivers/net/ethernet/adi/bfin_mac.h
> @@ -11,6 +11,7 @@
>  #define _BFIN_MAC_H_
>
>  #include <linux/net_tstamp.h>
> +#include <linux/ptp_clock_kernel.h>
>  #include <linux/timer.h>
>  #include <linux/etherdevice.h>
>  #include <linux/bfin_mac.h>
> @@ -94,7 +95,12 @@ struct bfin_mac_local {
>  #if defined(CONFIG_BFIN_MAC_USE_HWSTAMP)
>         u32 addend;
>         unsigned int shift;
> +       s32 max_ppb;
>         struct hwtstamp_config stamp_cfg;
> +       struct ptp_clock_info caps;
> +       struct ptp_clock *clock;
> +       int phc_index;
> +       spinlock_t phc_lock; /* protects time lo/hi registers */
>  #endif
>  };
>
> --
> 1.7.2.5
>



-- 
Regards,
--Bob

^ permalink raw reply

* Re: [PATCH V2 net-next 4/4] time: remove the timecompare code.
From: Bob Liu @ 2012-11-01  9:41 UTC (permalink / raw)
  To: Richard Cochran
  Cc: netdev, device-drivers-devel, uclinux-dist-devel, David Miller,
	Jacob Keller, Jeff Kirsher, John Ronciak, John Stultz,
	Mike Frysinger, Sonic Zhang
In-Reply-To: <962c27259144108f7f7033bb30ad9fa49630a9ce.1351696541.git.richardcochran@gmail.com>

On Thu, Nov 1, 2012 at 12:27 AM, Richard Cochran
<richardcochran@gmail.com> wrote:
> This patch removes the timecompare code from the kernel. The top five
> reasons to do this are:
>
> 1. There are no more users of this code.
> 2. The original idea was a bit weak.
> 3. The original author has disappeared.
> 4. The code was not general purpose but tuned to a particular hardware,
> 5. There are better ways to accomplish clock synchronization.
>
> Signed-off-by: Richard Cochran <richardcochran@gmail.com>

Tested-by: Bob Liu <lliubbo@gmail.com>

> Acked-by: John Stultz <john.stultz@linaro.org>
> ---
>  include/linux/timecompare.h |  125 ----------------------------
>  kernel/time/Makefile        |    2 +-
>  kernel/time/timecompare.c   |  193 -------------------------------------------
>  3 files changed, 1 insertions(+), 319 deletions(-)
>  delete mode 100644 include/linux/timecompare.h
>  delete mode 100644 kernel/time/timecompare.c
>
> diff --git a/include/linux/timecompare.h b/include/linux/timecompare.h
> deleted file mode 100644
> index 546e223..0000000
> --- a/include/linux/timecompare.h
> +++ /dev/null
> @@ -1,125 +0,0 @@
> -/*
> - * Utility code which helps transforming between two different time
> - * bases, called "source" and "target" time in this code.
> - *
> - * Source time has to be provided via the timecounter API while target
> - * time is accessed via a function callback whose prototype
> - * intentionally matches ktime_get() and ktime_get_real(). These
> - * interfaces where chosen like this so that the code serves its
> - * initial purpose without additional glue code.
> - *
> - * This purpose is synchronizing a hardware clock in a NIC with system
> - * time, in order to implement the Precision Time Protocol (PTP,
> - * IEEE1588) with more accurate hardware assisted time stamping.  In
> - * that context only synchronization against system time (=
> - * ktime_get_real()) is currently needed. But this utility code might
> - * become useful in other situations, which is why it was written as
> - * general purpose utility code.
> - *
> - * The source timecounter is assumed to return monotonically
> - * increasing time (but this code does its best to compensate if that
> - * is not the case) whereas target time may jump.
> - *
> - * The target time corresponding to a source time is determined by
> - * reading target time, reading source time, reading target time
> - * again, then assuming that average target time corresponds to source
> - * time. In other words, the assumption is that reading the source
> - * time is slow and involves equal time for sending the request and
> - * receiving the reply, whereas reading target time is assumed to be
> - * fast.
> - *
> - * Copyright (C) 2009 Intel Corporation.
> - * Author: Patrick Ohly <patrick.ohly@intel.com>
> - *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms and conditions of the GNU General Public License,
> - * version 2, as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope it will be useful, but WITHOUT
> - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - * FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for
> - * more details.
> - *
> - * You should have received a copy of the GNU General Public License along with
> - * this program; if not, write to the Free Software Foundation, Inc.,
> - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> - */
> -#ifndef _LINUX_TIMECOMPARE_H
> -#define _LINUX_TIMECOMPARE_H
> -
> -#include <linux/clocksource.h>
> -#include <linux/ktime.h>
> -
> -/**
> - * struct timecompare - stores state and configuration for the two clocks
> - *
> - * Initialize to zero, then set source/target/num_samples.
> - *
> - * Transformation between source time and target time is done with:
> - * target_time = source_time + offset +
> - *               (source_time - last_update) * skew /
> - *               TIMECOMPARE_SKEW_RESOLUTION
> - *
> - * @source:          used to get source time stamps via timecounter_read()
> - * @target:          function returning target time (for example, ktime_get
> - *                   for monotonic time, or ktime_get_real for wall clock)
> - * @num_samples:     number of times that source time and target time are to
> - *                   be compared when determining their offset
> - * @offset:          (target time - source time) at the time of the last update
> - * @skew:            average (target time - source time) / delta source time *
> - *                   TIMECOMPARE_SKEW_RESOLUTION
> - * @last_update:     last source time stamp when time offset was measured
> - */
> -struct timecompare {
> -       struct timecounter *source;
> -       ktime_t (*target)(void);
> -       int num_samples;
> -
> -       s64 offset;
> -       s64 skew;
> -       u64 last_update;
> -};
> -
> -/**
> - * timecompare_transform - transform source time stamp into target time base
> - * @sync:            context for time sync
> - * @source_tstamp:   the result of timecounter_read() or
> - *                   timecounter_cyc2time()
> - */
> -extern ktime_t timecompare_transform(struct timecompare *sync,
> -                                    u64 source_tstamp);
> -
> -/**
> - * timecompare_offset - measure current (target time - source time) offset
> - * @sync:            context for time sync
> - * @offset:          average offset during sample period returned here
> - * @source_tstamp:   average source time during sample period returned here
> - *
> - * Returns number of samples used. Might be zero (= no result) in the
> - * unlikely case that target time was monotonically decreasing for all
> - * samples (= broken).
> - */
> -extern int timecompare_offset(struct timecompare *sync,
> -                             s64 *offset,
> -                             u64 *source_tstamp);
> -
> -extern void __timecompare_update(struct timecompare *sync,
> -                                u64 source_tstamp);
> -
> -/**
> - * timecompare_update - update offset and skew by measuring current offset
> - * @sync:            context for time sync
> - * @source_tstamp:   the result of timecounter_read() or
> - *                   timecounter_cyc2time(), pass zero to force update
> - *
> - * Updates are only done at most once per second.
> - */
> -static inline void timecompare_update(struct timecompare *sync,
> -                                     u64 source_tstamp)
> -{
> -       if (!source_tstamp ||
> -           (s64)(source_tstamp - sync->last_update) >= NSEC_PER_SEC)
> -               __timecompare_update(sync, source_tstamp);
> -}
> -
> -#endif /* _LINUX_TIMECOMPARE_H */
> diff --git a/kernel/time/Makefile b/kernel/time/Makefile
> index e2fd74b..ff7d9d2 100644
> --- a/kernel/time/Makefile
> +++ b/kernel/time/Makefile
> @@ -1,4 +1,4 @@
> -obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o timecompare.o
> +obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o
>  obj-y += timeconv.o posix-clock.o alarmtimer.o
>
>  obj-$(CONFIG_GENERIC_CLOCKEVENTS_BUILD)                += clockevents.o
> diff --git a/kernel/time/timecompare.c b/kernel/time/timecompare.c
> deleted file mode 100644
> index a9ae369..0000000
> --- a/kernel/time/timecompare.c
> +++ /dev/null
> @@ -1,193 +0,0 @@
> -/*
> - * Copyright (C) 2009 Intel Corporation.
> - * Author: Patrick Ohly <patrick.ohly@intel.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> - */
> -
> -#include <linux/timecompare.h>
> -#include <linux/module.h>
> -#include <linux/slab.h>
> -#include <linux/math64.h>
> -#include <linux/kernel.h>
> -
> -/*
> - * fixed point arithmetic scale factor for skew
> - *
> - * Usually one would measure skew in ppb (parts per billion, 1e9), but
> - * using a factor of 2 simplifies the math.
> - */
> -#define TIMECOMPARE_SKEW_RESOLUTION (((s64)1)<<30)
> -
> -ktime_t timecompare_transform(struct timecompare *sync,
> -                             u64 source_tstamp)
> -{
> -       u64 nsec;
> -
> -       nsec = source_tstamp + sync->offset;
> -       nsec += (s64)(source_tstamp - sync->last_update) * sync->skew /
> -               TIMECOMPARE_SKEW_RESOLUTION;
> -
> -       return ns_to_ktime(nsec);
> -}
> -EXPORT_SYMBOL_GPL(timecompare_transform);
> -
> -int timecompare_offset(struct timecompare *sync,
> -                      s64 *offset,
> -                      u64 *source_tstamp)
> -{
> -       u64 start_source = 0, end_source = 0;
> -       struct {
> -               s64 offset;
> -               s64 duration_target;
> -       } buffer[10], sample, *samples;
> -       int counter = 0, i;
> -       int used;
> -       int index;
> -       int num_samples = sync->num_samples;
> -
> -       if (num_samples > ARRAY_SIZE(buffer)) {
> -               samples = kmalloc(sizeof(*samples) * num_samples, GFP_ATOMIC);
> -               if (!samples) {
> -                       samples = buffer;
> -                       num_samples = ARRAY_SIZE(buffer);
> -               }
> -       } else {
> -               samples = buffer;
> -       }
> -
> -       /* run until we have enough valid samples, but do not try forever */
> -       i = 0;
> -       counter = 0;
> -       while (1) {
> -               u64 ts;
> -               ktime_t start, end;
> -
> -               start = sync->target();
> -               ts = timecounter_read(sync->source);
> -               end = sync->target();
> -
> -               if (!i)
> -                       start_source = ts;
> -
> -               /* ignore negative durations */
> -               sample.duration_target = ktime_to_ns(ktime_sub(end, start));
> -               if (sample.duration_target >= 0) {
> -                       /*
> -                        * assume symetric delay to and from source:
> -                        * average target time corresponds to measured
> -                        * source time
> -                        */
> -                       sample.offset =
> -                               (ktime_to_ns(end) + ktime_to_ns(start)) / 2 -
> -                               ts;
> -
> -                       /* simple insertion sort based on duration */
> -                       index = counter - 1;
> -                       while (index >= 0) {
> -                               if (samples[index].duration_target <
> -                                   sample.duration_target)
> -                                       break;
> -                               samples[index + 1] = samples[index];
> -                               index--;
> -                       }
> -                       samples[index + 1] = sample;
> -                       counter++;
> -               }
> -
> -               i++;
> -               if (counter >= num_samples || i >= 100000) {
> -                       end_source = ts;
> -                       break;
> -               }
> -       }
> -
> -       *source_tstamp = (end_source + start_source) / 2;
> -
> -       /* remove outliers by only using 75% of the samples */
> -       used = counter * 3 / 4;
> -       if (!used)
> -               used = counter;
> -       if (used) {
> -               /* calculate average */
> -               s64 off = 0;
> -               for (index = 0; index < used; index++)
> -                       off += samples[index].offset;
> -               *offset = div_s64(off, used);
> -       }
> -
> -       if (samples && samples != buffer)
> -               kfree(samples);
> -
> -       return used;
> -}
> -EXPORT_SYMBOL_GPL(timecompare_offset);
> -
> -void __timecompare_update(struct timecompare *sync,
> -                         u64 source_tstamp)
> -{
> -       s64 offset;
> -       u64 average_time;
> -
> -       if (!timecompare_offset(sync, &offset, &average_time))
> -               return;
> -
> -       if (!sync->last_update) {
> -               sync->last_update = average_time;
> -               sync->offset = offset;
> -               sync->skew = 0;
> -       } else {
> -               s64 delta_nsec = average_time - sync->last_update;
> -
> -               /* avoid division by negative or small deltas */
> -               if (delta_nsec >= 10000) {
> -                       s64 delta_offset_nsec = offset - sync->offset;
> -                       s64 skew; /* delta_offset_nsec *
> -                                    TIMECOMPARE_SKEW_RESOLUTION /
> -                                    delta_nsec */
> -                       u64 divisor;
> -
> -                       /* div_s64() is limited to 32 bit divisor */
> -                       skew = delta_offset_nsec * TIMECOMPARE_SKEW_RESOLUTION;
> -                       divisor = delta_nsec;
> -                       while (unlikely(divisor >= ((s64)1) << 32)) {
> -                               /* divide both by 2; beware, right shift
> -                                  of negative value has undefined
> -                                  behavior and can only be used for
> -                                  the positive divisor */
> -                               skew = div_s64(skew, 2);
> -                               divisor >>= 1;
> -                       }
> -                       skew = div_s64(skew, divisor);
> -
> -                       /*
> -                        * Calculate new overall skew as 4/16 the
> -                        * old value and 12/16 the new one. This is
> -                        * a rather arbitrary tradeoff between
> -                        * only using the latest measurement (0/16 and
> -                        * 16/16) and even more weight on past measurements.
> -                        */
> -#define TIMECOMPARE_NEW_SKEW_PER_16 12
> -                       sync->skew =
> -                               div_s64((16 - TIMECOMPARE_NEW_SKEW_PER_16) *
> -                                       sync->skew +
> -                                       TIMECOMPARE_NEW_SKEW_PER_16 * skew,
> -                                       16);
> -                       sync->last_update = average_time;
> -                       sync->offset = offset;
> -               }
> -       }
> -}
> -EXPORT_SYMBOL_GPL(__timecompare_update);
> --
> 1.7.2.5
>



-- 
Regards,
--Bob

^ permalink raw reply

* Re: [PATCH V2 net-next 2/4] bfin_mac: replace sys time stamps with raw ones instead.
From: Bob Liu @ 2012-11-01  9:41 UTC (permalink / raw)
  To: Richard Cochran
  Cc: netdev, device-drivers-devel, uclinux-dist-devel, David Miller,
	Jacob Keller, Jeff Kirsher, John Ronciak, John Stultz,
	Mike Frysinger, Sonic Zhang
In-Reply-To: <b3bfe20bd4477e751d2e2b543b513d781eb0dd44.1351696541.git.richardcochran@gmail.com>

On Thu, Nov 1, 2012 at 12:27 AM, Richard Cochran
<richardcochran@gmail.com> wrote:
> This patch replaces the sys time stamps and timecompare code with simple
> raw hardware time stamps in nanosecond resolution. The only tricky bit is
> to find a PTP Hardware Clock period slower than the input clock period
> and a power of two.
>
> Compile tested only.
>
> Signed-off-by: Richard Cochran <richardcochran@gmail.com>

Tested-by: Bob Liu <lliubbo@gmail.com>

> ---
>  drivers/net/ethernet/adi/bfin_mac.c |   91 ++++++++++-------------------------
>  drivers/net/ethernet/adi/bfin_mac.h |    7 +--
>  2 files changed, 28 insertions(+), 70 deletions(-)
>
> diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
> index 2349abb..885fa80 100644
> --- a/drivers/net/ethernet/adi/bfin_mac.c
> +++ b/drivers/net/ethernet/adi/bfin_mac.c
> @@ -555,7 +555,7 @@ static int bfin_mac_ethtool_get_ts_info(struct net_device *dev,
>         info->so_timestamping =
>                 SOF_TIMESTAMPING_TX_HARDWARE |
>                 SOF_TIMESTAMPING_RX_HARDWARE |
> -               SOF_TIMESTAMPING_SYS_HARDWARE;
> +               SOF_TIMESTAMPING_RAW_HARDWARE;
>         info->phc_index = -1;
>         info->tx_types =
>                 (1 << HWTSTAMP_TX_OFF) |
> @@ -653,6 +653,20 @@ static int bfin_mac_set_mac_address(struct net_device *dev, void *p)
>  #ifdef CONFIG_BFIN_MAC_USE_HWSTAMP
>  #define bfin_mac_hwtstamp_is_none(cfg) ((cfg) == HWTSTAMP_FILTER_NONE)
>
> +static u32 bfin_select_phc_clock(u32 input_clk, unsigned int *shift_result)
> +{
> +       u32 ipn = 1000000000UL / input_clk;
> +       u32 ppn = 1;
> +       unsigned int shift = 0;
> +
> +       while (ppn <= ipn) {
> +               ppn <<= 1;
> +               shift++;
> +       }
> +       *shift_result = shift;
> +       return 1000000000UL / ppn;
> +}
> +
>  static int bfin_mac_hwtstamp_ioctl(struct net_device *netdev,
>                 struct ifreq *ifr, int cmd)
>  {
> @@ -802,19 +816,7 @@ static int bfin_mac_hwtstamp_ioctl(struct net_device *netdev,
>                 bfin_read_EMAC_PTP_TXSNAPLO();
>                 bfin_read_EMAC_PTP_TXSNAPHI();
>
> -               /*
> -                * Set registers so that rollover occurs soon to test this.
> -                */
> -               bfin_write_EMAC_PTP_TIMELO(0x00000000);
> -               bfin_write_EMAC_PTP_TIMEHI(0xFF800000);
> -
>                 SSYNC();
> -
> -               lp->compare.last_update = 0;
> -               timecounter_init(&lp->clock,
> -                               &lp->cycles,
> -                               ktime_to_ns(ktime_get_real()));
> -               timecompare_update(&lp->compare, 0);
>         }
>
>         lp->stamp_cfg = config;
> @@ -822,15 +824,6 @@ static int bfin_mac_hwtstamp_ioctl(struct net_device *netdev,
>                 -EFAULT : 0;
>  }
>
> -static void bfin_dump_hwtamp(char *s, ktime_t *hw, ktime_t *ts, struct timecompare *cmp)
> -{
> -       ktime_t sys = ktime_get_real();
> -
> -       pr_debug("%s %s hardware:%d,%d transform system:%d,%d system:%d,%d, cmp:%lld, %lld\n",
> -                       __func__, s, hw->tv.sec, hw->tv.nsec, ts->tv.sec, ts->tv.nsec, sys.tv.sec,
> -                       sys.tv.nsec, cmp->offset, cmp->skew);
> -}
> -
>  static void bfin_tx_hwtstamp(struct net_device *netdev, struct sk_buff *skb)
>  {
>         struct bfin_mac_local *lp = netdev_priv(netdev);
> @@ -861,15 +854,9 @@ static void bfin_tx_hwtstamp(struct net_device *netdev, struct sk_buff *skb)
>                         regval = bfin_read_EMAC_PTP_TXSNAPLO();
>                         regval |= (u64)bfin_read_EMAC_PTP_TXSNAPHI() << 32;
>                         memset(&shhwtstamps, 0, sizeof(shhwtstamps));
> -                       ns = timecounter_cyc2time(&lp->clock,
> -                                       regval);
> -                       timecompare_update(&lp->compare, ns);
> +                       ns = regval << lp->shift;
>                         shhwtstamps.hwtstamp = ns_to_ktime(ns);
> -                       shhwtstamps.syststamp =
> -                               timecompare_transform(&lp->compare, ns);
>                         skb_tstamp_tx(skb, &shhwtstamps);
> -
> -                       bfin_dump_hwtamp("TX", &shhwtstamps.hwtstamp, &shhwtstamps.syststamp, &lp->compare);
>                 }
>         }
>  }
> @@ -892,51 +879,25 @@ static void bfin_rx_hwtstamp(struct net_device *netdev, struct sk_buff *skb)
>
>         regval = bfin_read_EMAC_PTP_RXSNAPLO();
>         regval |= (u64)bfin_read_EMAC_PTP_RXSNAPHI() << 32;
> -       ns = timecounter_cyc2time(&lp->clock, regval);
> -       timecompare_update(&lp->compare, ns);
> +       ns = regval << lp->shift;
>         memset(shhwtstamps, 0, sizeof(*shhwtstamps));
>         shhwtstamps->hwtstamp = ns_to_ktime(ns);
> -       shhwtstamps->syststamp = timecompare_transform(&lp->compare, ns);
> -
> -       bfin_dump_hwtamp("RX", &shhwtstamps->hwtstamp, &shhwtstamps->syststamp, &lp->compare);
> -}
> -
> -/*
> - * bfin_read_clock - read raw cycle counter (to be used by time counter)
> - */
> -static cycle_t bfin_read_clock(const struct cyclecounter *tc)
> -{
> -       u64 stamp;
> -
> -       stamp =  bfin_read_EMAC_PTP_TIMELO();
> -       stamp |= (u64)bfin_read_EMAC_PTP_TIMEHI() << 32ULL;
> -
> -       return stamp;
>  }
>
> -#define PTP_CLK 25000000
> -
>  static void bfin_mac_hwtstamp_init(struct net_device *netdev)
>  {
>         struct bfin_mac_local *lp = netdev_priv(netdev);
> -       u64 append;
> +       u64 addend;
> +       u32 input_clk, phc_clk;
>
>         /* Initialize hardware timer */
> -       append = PTP_CLK * (1ULL << 32);
> -       do_div(append, get_sclk());
> -       bfin_write_EMAC_PTP_ADDEND((u32)append);
> -
> -       memset(&lp->cycles, 0, sizeof(lp->cycles));
> -       lp->cycles.read = bfin_read_clock;
> -       lp->cycles.mask = CLOCKSOURCE_MASK(64);
> -       lp->cycles.mult = 1000000000 / PTP_CLK;
> -       lp->cycles.shift = 0;
> -
> -       /* Synchronize our NIC clock against system wall clock */
> -       memset(&lp->compare, 0, sizeof(lp->compare));
> -       lp->compare.source = &lp->clock;
> -       lp->compare.target = ktime_get_real;
> -       lp->compare.num_samples = 10;
> +       input_clk = get_sclk();
> +       phc_clk = bfin_select_phc_clock(input_clk, &lp->shift);
> +       addend = phc_clk * (1ULL << 32);
> +       do_div(addend, input_clk);
> +       bfin_write_EMAC_PTP_ADDEND((u32)addend);
> +
> +       lp->addend = addend;
>
>         /* Initialize hwstamp config */
>         lp->stamp_cfg.rx_filter = HWTSTAMP_FILTER_NONE;
> diff --git a/drivers/net/ethernet/adi/bfin_mac.h b/drivers/net/ethernet/adi/bfin_mac.h
> index 960905c..57f042c 100644
> --- a/drivers/net/ethernet/adi/bfin_mac.h
> +++ b/drivers/net/ethernet/adi/bfin_mac.h
> @@ -11,8 +11,6 @@
>  #define _BFIN_MAC_H_
>
>  #include <linux/net_tstamp.h>
> -#include <linux/clocksource.h>
> -#include <linux/timecompare.h>
>  #include <linux/timer.h>
>  #include <linux/etherdevice.h>
>  #include <linux/bfin_mac.h>
> @@ -94,9 +92,8 @@ struct bfin_mac_local {
>         struct mii_bus *mii_bus;
>
>  #if defined(CONFIG_BFIN_MAC_USE_HWSTAMP)
> -       struct cyclecounter cycles;
> -       struct timecounter clock;
> -       struct timecompare compare;
> +       u32 addend;
> +       unsigned int shift;
>         struct hwtstamp_config stamp_cfg;
>  #endif
>  };
> --
> 1.7.2.5
>



-- 
Regards,
--Bob

^ permalink raw reply

* Re: [uclinux-dist-devel] [PATCH RFC net-next 2/4] bfin_mac: replace sys time stamps with raw ones instead.
From: Richard Cochran @ 2012-11-01  9:42 UTC (permalink / raw)
  To: Bob Liu
  Cc: netdev, Miroslav Lichvar, John Ronciak, John Stultz, Jeff Kirsher,
	device-drivers-devel, Jacob Keller, uclinux-dist-devel,
	Patrick Ohly, David Miller
In-Reply-To: <CAA_GA1e_NkFq49abibVtcyOcGp+AnP=yLbNPxmD3SdaAbWp+Jw@mail.gmail.com>

On Thu, Nov 01, 2012 at 05:39:01PM +0800, Bob Liu wrote:
> 
> Thank you very much.
> It works.

Thanks, Bob.

Can you add your Acked- or Tested-by to the V2 series that I posted?

Richard

^ permalink raw reply

* Re: [PATCH 4/9] net: openvswitch: use this_cpu_ptr per-cpu helper
From: Shan Wei @ 2012-11-01 10:07 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, NetDev, Kernel-Maillist, David Miller
In-Reply-To: <0000013ab7e86f8a-4adb8b81-19be-4264-96f1-924aaf3819f2-000000-p/GC64/jrecnJqMo6gzdpkEOCMrvLtNR@public.gmane.org>

Christoph Lameter said, at 2012/11/1 1:39:
> On Wed, 31 Oct 2012, Shan Wei wrote:
> 
>> --- a/net/openvswitch/datapath.c
>> +++ b/net/openvswitch/datapath.c
>> @@ -208,7 +208,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
>>  	int error;
>>  	int key_len;
>>
>> -	stats = per_cpu_ptr(dp->stats_percpu, smp_processor_id());
>> +	stats = this_cpu_ptr(dp->stats_percpu);
> 
> Well this is an improvement and may be ok if the preemption is disabled at
> this point. There is another possibility here to use this_cpu_read/add/inc
> instead of determining the pointer to the local cpu first and then
> performing operations on the fields. The pointer relocation with
> this_cpu_xxx ops is implicit in the instructions and safe against changing
> of processors. It would also save us the determination of a pointer to the
> current cpus stats structure.

yes, this_cpu_ptr just locate the point to current cpu per-cpu data domain.
and then operating [read/write/inc/sub] fields of this per-cpu variable
maybe on other cpu because task is rescheduled for preemption, interrupt.

But for different field in same per-cpu variable, how to guarantee n_missed
and n_hit are from same cpu? 
this_cpu_read(dp->stats_percpu->n_missed);
[processor changed]
this_cpu_read(dp->stats_percpu->n_hit);


In addition, following usage of per_cpu_ptr can be replaced by this_cpu_read.

cpu=get_cpu()
....
*per_cpu_ptr(p,cpu)
....
....
put_cpu()

^ permalink raw reply

* Re: [Suggestion] net-ipv6: format %8s change to %16s in rt6_info_route function of route.c
From: Chen Gang @ 2012-11-01 10:23 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: linux-kernel@vger.kernel.org, netdev
In-Reply-To: <1351760482.32673.913.camel@edumazet-glaptop>

于 2012年11月01日 17:01, Eric Dumazet 写道:
> Hi Chen
> 
> Thats a good suggestion indeed.
> 

  thank you very much for your confirmation.

> Networking patches should be sent to netdev@vger.kernel.org (added in
> CC)

  I will do it.

> 
> This list only cares about recent generic kernels, not RedHat ones.
> 

  it seems "it is not suitable to send any issues which only relative
with Red Hat to linux-*@vger.kernel.org".



> If you want to provide a patch, please base it on David Miller net-next
> [1] tree, and make it official (read Documentation/SubmittingPatches for
> general advices)
> 

  ok, I will follow, thank you for your information.


> By the way, the %8s should be replaced by %s, there is no need to make
> /proc/net/ipv6_route 'beautiful'. In the past, it was *needed* because
> each line had to be of a given length, but its not anymore the case.
> 
> Thanks
> 

1) I agree with your result.

2) But for the "reason", I have my opinions:
   A) %.8s :  for limitation of output string length.
   B) %8s  :  for width of output string length (but not limit 8).
   C) %8.8s:  both limitation and width.

3) for rt->rt6i_dev->name:
   A) original %8s is not a bug for name len is more than 8 (can still
be outputted correctly)
   B) it is only effect with name len is less than 8 (it will fill some
' ' before the name)
   C) this is the reason why I call it "beautiful", not a bug.


> [1] :
> http://git.kernel.org/?p=linux/kernel/git/davem/net-next.git;a=summary
> 

  I will reference it, thanks.


-- 
Chen Gang

Asianux Corporation

^ permalink raw reply

* [PATCH v2 RESEND 0/6] Calxeda xgmac performance fixes
From: Rob Herring @ 2012-11-01 10:40 UTC (permalink / raw)
  To: netdev, davem; +Cc: eric.dumazet, Rob Herring

From: Rob Herring <rob.herring@calxeda.com>

This is a repost for 3.8 inclusion. Only patch 5 has changed from v1
and was previously posted.

This is a series of performance improvements to the xgmac driver. The
most significant changes are the alignment fixes to avoid alignment
traps on received frames and using relaxed i/o accessors.

Rob

Rob Herring (6):
  net: calxedaxgmac: enable operate on 2nd frame mode
  net: calxedaxgmac: remove explicit rx dma buffer polling
  net: calxedaxgmac: use relaxed i/o accessors in rx and tx paths
  net: calxedaxgmac: drop some unnecessary register writes
  net: calxedaxgmac: rework transmit ring handling
  net: calxedaxgmac: ip align receive buffers

 drivers/net/ethernet/calxeda/Kconfig |    2 +-
 drivers/net/ethernet/calxeda/xgmac.c |   59 +++++++++++++++-------------------
 2 files changed, 27 insertions(+), 34 deletions(-)

-- 
1.7.10.4

^ permalink raw reply

* [PATCH v2 RESEND 1/6] net: calxedaxgmac: enable operate on 2nd frame mode
From: Rob Herring @ 2012-11-01 10:40 UTC (permalink / raw)
  To: netdev, davem; +Cc: eric.dumazet, Rob Herring
In-Reply-To: <1351766464-27354-1-git-send-email-robherring2@gmail.com>

From: Rob Herring <rob.herring@calxeda.com>

Enable the tx dma to start reading the next frame while sending the current
frame.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 drivers/net/ethernet/calxeda/xgmac.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
index 16814b3..7f5fd17 100644
--- a/drivers/net/ethernet/calxeda/xgmac.c
+++ b/drivers/net/ethernet/calxeda/xgmac.c
@@ -191,6 +191,7 @@
 #define DMA_CONTROL_ST		0x00002000	/* Start/Stop Transmission */
 #define DMA_CONTROL_SR		0x00000002	/* Start/Stop Receive */
 #define DMA_CONTROL_DFF		0x01000000	/* Disable flush of rx frames */
+#define DMA_CONTROL_OSF		0x00000004	/* Operate on 2nd tx frame */
 
 /* DMA Normal interrupt */
 #define DMA_INTR_ENA_NIE	0x00010000	/* Normal Summary */
@@ -965,8 +966,7 @@ static int xgmac_hw_init(struct net_device *dev)
 		ctrl |= XGMAC_CONTROL_IPC;
 	writel(ctrl, ioaddr + XGMAC_CONTROL);
 
-	value = DMA_CONTROL_DFF;
-	writel(value, ioaddr + XGMAC_DMA_CONTROL);
+	writel(DMA_CONTROL_DFF | DMA_CONTROL_OSF, ioaddr + XGMAC_DMA_CONTROL);
 
 	/* Set the HW DMA mode and the COE */
 	writel(XGMAC_OMR_TSF | XGMAC_OMR_RFD | XGMAC_OMR_RFA |
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH v2 RESEND 2/6] net: calxedaxgmac: remove explicit rx dma buffer polling
From: Rob Herring @ 2012-11-01 10:41 UTC (permalink / raw)
  To: netdev, davem; +Cc: eric.dumazet, Rob Herring
In-Reply-To: <1351766464-27354-1-git-send-email-robherring2@gmail.com>

From: Rob Herring <rob.herring@calxeda.com>

New received frames will trigger the rx DMA to poll the DMA descriptors,
so there is no need to tell the h/w to poll. We also want to enable
dropping frames from the fifo when there is no buffer.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 drivers/net/ethernet/calxeda/xgmac.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
index 7f5fd17..728fcef 100644
--- a/drivers/net/ethernet/calxeda/xgmac.c
+++ b/drivers/net/ethernet/calxeda/xgmac.c
@@ -966,7 +966,7 @@ static int xgmac_hw_init(struct net_device *dev)
 		ctrl |= XGMAC_CONTROL_IPC;
 	writel(ctrl, ioaddr + XGMAC_CONTROL);
 
-	writel(DMA_CONTROL_DFF | DMA_CONTROL_OSF, ioaddr + XGMAC_DMA_CONTROL);
+	writel(DMA_CONTROL_OSF, ioaddr + XGMAC_DMA_CONTROL);
 
 	/* Set the HW DMA mode and the COE */
 	writel(XGMAC_OMR_TSF | XGMAC_OMR_RFD | XGMAC_OMR_RFA |
@@ -1180,8 +1180,6 @@ static int xgmac_rx(struct xgmac_priv *priv, int limit)
 
 	xgmac_rx_refill(priv);
 
-	writel(1, priv->base + XGMAC_DMA_RX_POLL);
-
 	return count;
 }
 
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH v2 RESEND 3/6] net: calxedaxgmac: use relaxed i/o accessors in rx and tx paths
From: Rob Herring @ 2012-11-01 10:41 UTC (permalink / raw)
  To: netdev, davem; +Cc: eric.dumazet, Rob Herring
In-Reply-To: <1351766464-27354-1-git-send-email-robherring2@gmail.com>

From: Rob Herring <rob.herring@calxeda.com>

The standard readl/writel accessors involve a spinlock and cache sync
operation on ARM platforms with an outer cache. Only DMA triggering
accesses need this, so use the relaxed variants instead.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 drivers/net/ethernet/calxeda/Kconfig |    2 +-
 drivers/net/ethernet/calxeda/xgmac.c |   12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/calxeda/Kconfig b/drivers/net/ethernet/calxeda/Kconfig
index aba435c..6a4ddf6 100644
--- a/drivers/net/ethernet/calxeda/Kconfig
+++ b/drivers/net/ethernet/calxeda/Kconfig
@@ -1,6 +1,6 @@
 config NET_CALXEDA_XGMAC
 	tristate "Calxeda 1G/10G XGMAC Ethernet driver"
-	depends on HAS_IOMEM
+	depends on HAS_IOMEM && ARM
 	select CRC32
 	help
 	  This is the driver for the XGMAC Ethernet IP block found on Calxeda
diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
index 728fcef..117839e 100644
--- a/drivers/net/ethernet/calxeda/xgmac.c
+++ b/drivers/net/ethernet/calxeda/xgmac.c
@@ -1203,7 +1203,7 @@ static int xgmac_poll(struct napi_struct *napi, int budget)
 
 	if (work_done < budget) {
 		napi_complete(napi);
-		writel(DMA_INTR_DEFAULT_MASK, priv->base + XGMAC_DMA_INTR_ENA);
+		writel_relaxed(DMA_INTR_DEFAULT_MASK, priv->base + XGMAC_DMA_INTR_ENA);
 	}
 	return work_done;
 }
@@ -1348,7 +1348,7 @@ static irqreturn_t xgmac_pmt_interrupt(int irq, void *dev_id)
 	struct xgmac_priv *priv = netdev_priv(dev);
 	void __iomem *ioaddr = priv->base;
 
-	intr_status = readl(ioaddr + XGMAC_INT_STAT);
+	intr_status = readl_relaxed(ioaddr + XGMAC_INT_STAT);
 	if (intr_status & XGMAC_INT_STAT_PMT) {
 		netdev_dbg(priv->dev, "received Magic frame\n");
 		/* clear the PMT bits 5 and 6 by reading the PMT */
@@ -1366,9 +1366,9 @@ static irqreturn_t xgmac_interrupt(int irq, void *dev_id)
 	struct xgmac_extra_stats *x = &priv->xstats;
 
 	/* read the status register (CSR5) */
-	intr_status = readl(priv->base + XGMAC_DMA_STATUS);
-	intr_status &= readl(priv->base + XGMAC_DMA_INTR_ENA);
-	writel(intr_status, priv->base + XGMAC_DMA_STATUS);
+	intr_status = readl_relaxed(priv->base + XGMAC_DMA_STATUS);
+	intr_status &= readl_relaxed(priv->base + XGMAC_DMA_INTR_ENA);
+	writel_relaxed(intr_status, priv->base + XGMAC_DMA_STATUS);
 
 	/* It displays the DMA process states (CSR5 register) */
 	/* ABNORMAL interrupts */
@@ -1404,7 +1404,7 @@ static irqreturn_t xgmac_interrupt(int irq, void *dev_id)
 
 	/* TX/RX NORMAL interrupts */
 	if (intr_status & (DMA_STATUS_RI | DMA_STATUS_TU)) {
-		writel(DMA_INTR_ABNORMAL, priv->base + XGMAC_DMA_INTR_ENA);
+		writel_relaxed(DMA_INTR_ABNORMAL, priv->base + XGMAC_DMA_INTR_ENA);
 		napi_schedule(&priv->napi);
 	}
 
-- 
1.7.10.4

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox