Gigabit Ethernet driver of Topcliff PCH
Subsystems (2)
PATCH 1/1 Gigabit Ethernet driver of Topcliff PCH
---
Gigabit Ethernet driver of Topcliff PCH
Topcliff PCH is the platform controller hub that is going to be used in Intel's upcoming general embedded platform. All IO peripherals in Topcliff PCH are actually devices sitting on AMBA bus. Topcliff PCH has Gigabit Ethernet I/F. Using this I/F, it is able to access system devices connected to Gigabit Ethernet.
--- drivers/net/Kconfig | 5 + drivers/net/Makefile | 1 + drivers/net/pch_gbe/Makefile | 6 + drivers/net/pch_gbe/pch_gbe.h | 425 ++++++ drivers/net/pch_gbe/pch_gbe_api.c | 247 +++ drivers/net/pch_gbe/pch_gbe_api.h | 31 + drivers/net/pch_gbe/pch_gbe_ethtool.c | 623 ++++++++ drivers/net/pch_gbe/pch_gbe_main.c | 2695 +++++++++++++++++++++++++++++++++ drivers/net/pch_gbe/pch_gbe_param.c | 516 +++++++ drivers/net/pch_gbe/pch_gbe_phy.c | 277 ++++ drivers/net/pch_gbe/pch_gbe_phy.h | 32 + drivers/net/pch_gbe/pch_gbe_regs.h | 305 ++++ 12 files changed, 5163 insertions(+), 0 deletions(-) create mode 100644 drivers/net/pch_gbe/Makefile create mode 100644 drivers/net/pch_gbe/Module.symvers create mode 100644 drivers/net/pch_gbe/pch_gbe.h create mode 100644 drivers/net/pch_gbe/pch_gbe_api.c create mode 100644 drivers/net/pch_gbe/pch_gbe_api.h create mode 100644 drivers/net/pch_gbe/pch_gbe_ethtool.c create mode 100644 drivers/net/pch_gbe/pch_gbe_main.c create mode 100644 drivers/net/pch_gbe/pch_gbe_param.c create mode 100644 drivers/net/pch_gbe/pch_gbe_phy.c create mode 100644 drivers/net/pch_gbe/pch_gbe_phy.h create mode 100644 drivers/net/pch_gbe/pch_gbe_regs.h
drivers/net/Kconfig +5 -0
@@ -2004,6 +2004,11 @@ menuconfig NETDEV_1000 If you say N, all options in this submenu will be skipped and disabled. if NETDEV_1000 +config PCH_GBE + tristate "PCH Gigabit Ethernet" + ---help--- + This is an gigabit ethernet driver for PCH. + resources. config ACENIC tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support"
drivers/net/Makefile +1 -0
@@ -295,3 +295,4 @@ obj-$(CONFIG_WIMAX) += wimax/ obj-$(CONFIG_CAIF) += caif/ obj-$(CONFIG_OCTEON_MGMT_ETHERNET) += octeon/ +obj-$(CONFIG_PCH_GBE) += pch_gbe/
drivers/net/pch_gbe/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +ifeq ($(CONFIG_PCH_GBE_DEBUG_CORE),y) +EXTRA_CFLAGS += -DDEBUG +endif + +obj-$(CONFIG_PCH_GBE) += pch_gbe.o +pch_gbe-objs := pch_gbe_phy.o pch_gbe_ethtool.o pch_gbe_param.o pch_gbe_api.o pch_gbe_main.o
drivers/net/pch_gbe/Module.symvers new file +0 -0
drivers/net/pch_gbe/pch_gbe.h new file +425 -0
425 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_api.c new file +247 -0
247 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_api.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD. +* +* 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; version 2 of the License. +* +* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef _PCH_GBE_API_H_ +#define _PCH_GBE_API_H_ + +s32 pch_gbe_hal_setup_init_funcs (struct pch_gbe_hw *hw); +void pch_gbe_hal_get_bus_info (struct pch_gbe_hw *hw); +s32 pch_gbe_hal_init_hw (struct pch_gbe_hw *hw); +s32 pch_gbe_hal_read_phy_reg (struct pch_gbe_hw *hw,u32 offset,u16 *data); +s32 pch_gbe_hal_write_phy_reg (struct pch_gbe_hw *hw,u32 offset,u16 data); +void pch_gbe_hal_phy_hw_reset (struct pch_gbe_hw *hw); +void pch_gbe_hal_phy_sw_reset (struct pch_gbe_hw *hw); +s32 pch_gbe_hal_read_mac_addr (struct pch_gbe_hw *hw); +void pch_gbe_hal_power_up_phy (struct pch_gbe_hw *hw); +void pch_gbe_hal_power_down_phy (struct pch_gbe_hw *hw); + +#endif
drivers/net/pch_gbe/pch_gbe_ethtool.c new file +623 -0
623 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_main.c new file +2695 -0
1,653 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_param.c new file +516 -0
516 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_phy.c new file +277 -0
277 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_phy.h new file +32 -0
Lines of this file are not shown. View the raw message.
drivers/net/pch_gbe/pch_gbe_regs.h new file +305 -0
305 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
-- 1.6.2.5
Part of the diff is not shown here. View the raw message.
Hi Masayuki Ohtake.
Just a few comments after a very quick scan over some of the files.
Sam
Quoted 1 line · Masayuki Ohtake
---
"---" is used to truncate your changelog, random comments goes below "---". So there would be no changelog entry in this case.
drivers/net/Kconfig menuconfig NETDEV_1000 · line 2011
Quoted 13 lines
drivers/net/Kconfig +5
-0@@ -2004,6 +2004,11 @@ menuconfig NETDEV_1000 If you say N, all options in this submenu will be skipped and disabled. if NETDEV_1000 +config PCH_GBE + tristate "PCH Gigabit Ethernet" + ---help--- + This is an gigabit ethernet driver for PCH. + resources.
Naive readers do not know what PCH is.
Google says it is: Potlatch Corporation
Please elaborate much more.
For new stuff we use "help" - not "---help---". But you could not know as this is not documented anywhere.
drivers/net/pch_gbe/Makefile line 3
Quoted 9 lines
drivers/net/pch_gbe/Makefile new file +3
-0@@ -0,0 +1,6 @@ +ifeq ($(CONFIG_PCH_GBE_DEBUG_CORE),y) +EXTRA_CFLAGS += -DDEBUG +endif
Use:
ccflags-$(CONFIG_PCH_GBE_DEBUG_CORE) := -DDEBUG
Btw. where do CONFIG_PCH_GBE_DEBUG_CORE come from. It was not in the Kconfig file you included.
drivers/net/pch_gbe/Makefile line 6
Quoted 3 lines
drivers/net/pch_gbe/Makefile new file +3
-0+ +obj-$(CONFIG_PCH_GBE) += pch_gbe.o +pch_gbe-objs := pch_gbe_phy.o pch_gbe_ethtool.o pch_gbe_param.o pch_gbe_api.o pch_gbe_main.o
Please do not use -objs.
Do like this:
obj-$(CONFIG_PCH_GBE) += pch_gbe.o
pch_gbe-y := pch_gbe_phy.o pch_gbe_ethtool.o pch_gbe_param.o pch_gbe-y += pch_gbe_api.o pch_gbe_main.o
drivers/net/pch_gbe/Module.symvers
Quoted 3 lines
drivers/net/pch_gbe/Module.symvers new file +0
-0
This file should be dropped.
Quoted 23 lines
drivers/net/pch_gbe/pch_gbe.h new file +17
-0@@ -0,0 +1,425 @@ +/* +* Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD. +* +* 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; version 2 of the License. +* +* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +*/ +
drivers/net/pch_gbe/pch_gbe.h line 27
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe.h new file +10
-0+#ifndef _PCH_GBE_H_ +#define _PCH_GBE_H_ + +#include <linux/netdevice.h> +#include <linux/mii.h> + +#undef FALSE +#define FALSE 0 +#undef TRUE +#define TRUE 1
Use true/false - no reason for these.
drivers/net/pch_gbe/pch_gbe.h line 34
Quoted 7 lines
drivers/net/pch_gbe/pch_gbe.h new file +7
-0+ +#ifdef DEBUG +#define PCH_GBE_DEBUG(fmt, args...)\ + printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, ##args) +#else +#define PCH_GBE_DEBUG(fmt, args...) do { } while (0) +#endif
Use standard logging methods.
pr_* and similar.
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe.h new file +10
-0+ +/* Device Driver infomation */ +#define DRV_STRING "PCH Network Driver" +#define DRV_EXT "-NAPI" +#define DRV_VERSION "0.95"DRV_EXT +#define DRV_DESCRIPTION \ + "OKI semiconductor sample Linux driver for PCH Gigabit ethernet" +#define DRV_COPYRIGHT "Copyright(c) 2010 OKI semiconductor" +#define FIRM_VERSION "N/A" +/* TX/RX descriptor defines */
drivers/net/pch_gbe/pch_gbe.h line 53
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe.h new file +9
-0+#define PCH_GBE_MAX_TXD 4096 +#define PCH_GBE_MIN_TXD 8 +#define PCH_GBE_MAX_RXD 4096 +#define PCH_GBE_MIN_RXD 8 +/* Number of Transmit and Receive Descriptors must be a multiple of 8 */ +#define PCH_GBE_TX_DESC_MULTIPLE 8 +#define PCH_GBE_RX_DESC_MULTIPLE 8 +/* only works for sizes that are powers of 2 */ +#define PCH_GBE_ROUNDUP (i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
We have this already. Search include/linux/*
drivers/net/pch_gbe/pch_gbe.h line 89
Quoted 7 lines
+ * @read_mac_addr: for
pch_gbe_hal_read_mac_addr
+ */drivers/net/pch_gbe/pch_gbe.h new file +5
-0+struct pch_gbe_functions { +void (*get_bus_info) (struct pch_gbe_hw *); +s32 (*init_hw) (struct pch_gbe_hw *); +s32 (*read_phy_reg) (struct pch_gbe_hw *,u32 ,u16 *); +s32 (*write_phy_reg) (struct pch_gbe_hw *,u32 ,u16 );
missign space after s32
drivers/net/pch_gbe/pch_gbe.h
Quoted 11 lines
drivers/net/pch_gbe/pch_gbe.h new file +8
-0+void (*reset_phy) (struct pch_gbe_hw *); +void (*sw_reset_phy) (struct pch_gbe_hw *); +void (*power_up_phy) (struct pch_gbe_hw *hw); +void (*power_down_phy) (struct pch_gbe_hw *hw); +s32 (*read_mac_addr) (struct pch_gbe_hw *); +}; + + printk(KERN_ERR KBUILD_MODNAME ": " "ERROR: Registers not mapped\n");
In several places...
Use standard logging methods to do this simpler.
drivers/net/pch_gbe/pch_gbe.h line 1
Quoted 3 lines
+++
b/drivers/net/pch_gbe/pch_gbe_api.hdrivers/net/pch_gbe/pch_gbe.h new file +1
-0@@ -0,0 +1,31 @@ +/*
Why is two .h files needed for a single driver?
As this file live in drivers/net/pch_gbe/ this is purely internal stuff.
drivers/net/pch_gbe/pch_gbe.h line 4
Quoted 3 lines
drivers/net/pch_gbe/pch_gbe.h new file +3
-0+#include "pch_gbe_regs.h" +#include "pch_gbe.h" +#include "pch_gbe_api.h"
As per comment above I realise that this single driver has three .h files. Maybe their size warrants this?
Hi Sam
Thank you for your comment.
The reply's comment was buried in following.
I will modify this patch.
Thanks, Ohtake(OKISEMI)
----- Original Message -----
From: "Sam Ravnborg" <[email protected]>
To: "Masayuki Ohtake" <[email protected]>
Cc: "LKML" <[email protected]>; "ML netdev" <[email protected]>; "Greg Rose" <[email protected]>; "Maxime Bizon" <[email protected]>; "Kristoffer Glembo" <[email protected]>; "Ralf Baechle" <[email protected]>; "John Linn" <[email protected]>; "Randy Dunlap" <[email protected]>; "David S. Miller" <[email protected]>; "MeeGo" <[email protected]>; "Wang, Qi" <[email protected]>; "Wang, Yong Y" <[email protected]>; "Andrew" <[email protected]>; "Intel OTC" <[email protected]>; "Foster, Margie" <[email protected]>; "Toshiharu Okada" <[email protected]>; "Tomoya Morinaga" <[email protected]>; "Takahiro Shimizu" <[email protected]>
Sent: Thursday, August 26, 2010 7:28 PM
Subject: Re: [PATCH] Gigabit Ethernet driver of Topcliff PCH
Quoted 11 lines
Hi Masayuki Ohtake.
Just a few comments after a very quick scan over some of the files.
Sam
Quoted 1 line · Masayuki Ohtake
---
"---" is used to truncate your changelog, random comments goes below "---". So there would be no changelog entry in this case.
<masa>
OK
Quoted 18 lines
Quoted 6 lines
drivers/net/Kconfig +0
-0drivers/net/Kconfig menuconfig NETDEV_1000 · line 2011
Quoted 8 lines
drivers/net/Kconfig +5
-0@@ -2004,6 +2004,11 @@ menuconfig NETDEV_1000 If you say N, all options in this submenu will be skipped and disabled. if NETDEV_1000 +config PCH_GBE + tristate "PCH Gigabit Ethernet" + ---help--- + This is an gigabit ethernet driver for PCH. + resources.Naive readers do not know what PCH is.
Google says it is: Potlatch Corporation
Quoted 4 lines
Please elaborate much more.
For new stuff we use "help" - not "---help---". But you could not know as this is not documented anywhere.
<masa>
Topcliff PCH is the platform controller hub that is going to be used in Intel's upcoming general embedded platform.
Explanation is added to help.
Quoted 13 lines
drivers/net/pch_gbe/Makefile line 3
Quoted 10 lines
drivers/net/pch_gbe/Makefile new file +3
-0@@ -0,0 +1,6 @@ +ifeq ($(CONFIG_PCH_GBE_DEBUG_CORE),y) +EXTRA_CFLAGS += -DDEBUG +endifUse:
ccflags-$(CONFIG_PCH_GBE_DEBUG_CORE) := -DDEBUG
Quoted 3 lines
Btw. where do
CONFIG_PCH_GBE_DEBUG_COREcome from. It was not in theKconfigfile you included.
<masa>
This deletes.
Since a standard logging is used
Quoted 11 lines
drivers/net/pch_gbe/Makefile line 6
Quoted 3 lines
drivers/net/pch_gbe/Makefile new file +3
-0+ +obj-$(CONFIG_PCH_GBE) += pch_gbe.o +pch_gbe-objs := pch_gbe_phy.o pch_gbe_ethtool.o pch_gbe_param.o pch_gbe_api.o pch_gbe_main.oPlease do not use -objs.
Do like this:obj-$(CONFIG_PCH_GBE) += pch_gbe.o
pch_gbe-y := pch_gbe_phy.o pch_gbe_ethtool.o pch_gbe_param.o pch_gbe-y += pch_gbe_api.o pch_gbe_main.o
<masa>
This modifies as above.
Quoted 5 lines
drivers/net/pch_gbe/Module.symvers
Quoted 4 lines
drivers/net/pch_gbe/Module.symvers new file +0
-0This file should be dropped.
<masa>
This modifies
Quoted 27 lines
Quoted 27 lines
drivers/net/pch_gbe/pch_gbe.h new file +20
-0@@ -0,0 +1,425 @@ +/* +* Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD. +* +* 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; version 2 of the License. +* +* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef _PCH_GBE_H_ +#define _PCH_GBE_H_ +
Quoted 9 lines
drivers/net/pch_gbe/pch_gbe.h line 27
Quoted 7 lines
drivers/net/pch_gbe/pch_gbe.h new file +7
-0+#include <linux/netdevice.h> +#include <linux/mii.h> + +#undef FALSE +#define FALSE 0 +#undef TRUE +#define TRUE 1Use true/false - no reason for these.
<masa>
This modifies
Quoted 11 lines
drivers/net/pch_gbe/pch_gbe.h line 34
Quoted 7 lines
drivers/net/pch_gbe/pch_gbe.h new file +7
-0+ +#ifdef DEBUG +#define PCH_GBE_DEBUG(fmt, args...)\ + printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, ##args) +#else +#define PCH_GBE_DEBUG(fmt, args...) do { } while (0) +#endif Use standard logging methods.
pr_* and similar.
<masa>
This modifies
Quoted 19 lines
Quoted 18 lines
drivers/net/pch_gbe/pch_gbe.h new file +17
-0+ +/* Device Driver infomation */ +#define DRV_STRING "PCH Network Driver" +#define DRV_EXT "-NAPI" +#define DRV_VERSION "0.95"DRV_EXT +#define DRV_DESCRIPTION \ + "OKI semiconductor sample Linux driver for PCH Gigabit ethernet" +#define DRV_COPYRIGHT "Copyright(c) 2010 OKI semiconductor" +#define FIRM_VERSION "N/A" +/* TX/RX descriptor defines */ +#define PCH_GBE_MAX_TXD 4096 +#define PCH_GBE_MIN_TXD 8 +#define PCH_GBE_MAX_RXD 4096 +#define PCH_GBE_MIN_RXD 8 +/* Number of Transmit and Receive Descriptors must be a multiple of 8 */ +#define PCH_GBE_TX_DESC_MULTIPLE 8 +#define PCH_GBE_RX_DESC_MULTIPLE 8
Quoted 4 lines
drivers/net/pch_gbe/pch_gbe.h line 53
Quoted 2 lines
drivers/net/pch_gbe/pch_gbe.h new file +2
-0+/* only works for sizes that are powers of 2 */ +#define PCH_GBE_ROUNDUP (i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))We have this already. Search
include/linux/*
<masa>
This modifies
Quoted 9 lines
drivers/net/pch_gbe/pch_gbe.h line 89
Quoted 7 lines
drivers/net/pch_gbe/pch_gbe.h new file +7
-0+* @read_mac_addr: for pch_gbe_hal_read_mac_addr +*/ +struct pch_gbe_functions { +void (*get_bus_info) (struct pch_gbe_hw *); +s32 (*init_hw) (struct pch_gbe_hw *); +s32 (*read_phy_reg) (struct pch_gbe_hw *,u32 ,u16 *); +s32 (*write_phy_reg) (struct pch_gbe_hw *,u32 ,u16 );missign space after s32
<masa>
This modifies
Quoted 10 lines
Quoted 7 lines
drivers/net/pch_gbe/pch_gbe.h new file +7
-0+void (*reset_phy) (struct pch_gbe_hw *); +void (*sw_reset_phy) (struct pch_gbe_hw *); +void (*power_up_phy) (struct pch_gbe_hw *hw); +void (*power_down_phy) (struct pch_gbe_hw *hw); +s32 (*read_mac_addr) (struct pch_gbe_hw *); +}; +
Quoted 4 lines
drivers/net/pch_gbe/pch_gbe.h line 68
Quoted 1 line
drivers/net/pch_gbe/pch_gbe.h new file +1
-0+ printk(KERN_ERR KBUILD_MODNAME ": " "ERROR: Registers not mapped\n");In several places...
Use standard logging methods to do this simpler.
<masa>
This modifies
Quoted 8 lines
drivers/net/pch_gbe/pch_gbe.h line 1
Quoted 5 lines
drivers/net/pch_gbe/pch_gbe.h new file +2
-0+++ b/drivers/net/pch_gbe/pch_gbe_api.h@@ -0,0 +1,31 @@ +/* Why is two .h files needed for a single driver?
As this file live indrivers/net/pch_gbe/this is purely internal stuff.
<masa>
This driver is designed be easy to add other PHY.
The api.c/h wraps the interface of PHY.
Quoted 8 lines
drivers/net/pch_gbe/pch_gbe.h line 4
Quoted 4 lines
drivers/net/pch_gbe/pch_gbe.h new file +3
-0+#include "pch_gbe_regs.h" +#include "pch_gbe.h" +#include "pch_gbe_api.h" As per comment above I realise that this single driver has three .h files. Maybe their size warrants this?
<masa>
"pch_gbe_regs.h" shows the register of MAC.
"pch_gbe_regs.h" is merged into "pch_gbe.h".
Quoted 2 lines · Masayuki Ohtake
Gigabit Ethernet driver of Topcliff PCH
+++b/drivers/net/pch_gbe/pch_gbe.h
Just a few style comments
drivers/net/pch_gbe/pch_gbe.h line 27
Quoted 4 lines
drivers/net/pch_gbe/pch_gbe.h new file +4
-0+#undef FALSE +#define FALSE 0 +#undef TRUE +#define TRUE 1
Perhaps better to use the kernel true/false.
drivers/net/pch_gbe/pch_gbe.h line 34
Quoted 6 lines
drivers/net/pch_gbe/pch_gbe.h new file +6
-0+#ifdef DEBUG +#define PCH_GBE_DEBUG(fmt, args...)\ + printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, ##args) +#else +#define PCH_GBE_DEBUG(fmt, args...) do { } while (0) +#endif
Better to use
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
and
pr_debug(fmt, ...);
[]
drivers/net/pch_gbe/pch_gbe.h line 88
Quoted 4 lines
drivers/net/pch_gbe/pch_gbe.h new file +4
-0+struct pch_gbe_functions { +void (*get_bus_info) (struct pch_gbe_hw *); +s32 (*init_hw) (struct pch_gbe_hw *); +s32 (*read_phy_reg) (struct pch_gbe_hw *,u32 ,u16 *);
Trivial: Inconsistent spacing (a few times)
Perhaps:
s32 (*read_phy_reg) etc...
drivers/net/pch_gbe/pch_gbe.h line 90
Quoted 2 lines
drivers/net/pch_gbe/pch_gbe.h new file +2
-0+s32 (*write_phy_reg) (struct pch_gbe_hw *,u32 ,u16 ); +void (*reset_phy) (struct pch_gbe_hw *);
[]
Review
Quoted 4 lines
(quoted diff) +2
-0+ s32(*read_mac_addr) (struct pch_gbe_hw *); +++ b/drivers/net/pch_gbe/pch_gbe_api.c@@ -0,0 +1,247 @@
[]
Convert all the
printk(KERN_<level> KBUILD_MODNAME ": " etc
to
pr_<level>(etc
Review line 2
Quoted 2 lines
(quoted diff) +2
-0+#include "pch_gbe.h" +#include "pch_gbe_phy.h"
[]
drivers/net/pch_gbe/pch_gbe_api.c line 72
Quoted 8 lines
drivers/net/pch_gbe/pch_gbe_api.c new file +8
-0+static s32 pch_gbe_plat_init_hw (struct pch_gbe_hw *hw) +{ +s32 ret_val; + + ret_val =pch_gbe_phy_get_id (hw); +if (ret_val) { + printk(KERN_ERR KBUILD_MODNAME ": " + "pch_gbe_phy_get_id error\n");
pr_err("pch_gbe_phy_get_id error\n");drivers/net/pch_gbe/pch_gbe_api.c line 119
Quoted 7 lines
drivers/net/pch_gbe/pch_gbe_api.c new file +7
-0+inline s32 pch_gbe_hal_setup_init_funcs (struct pch_gbe_hw *hw) +{ +if (hw->reg) { +pch_gbe_plat_init_function_pointers (hw); +return 0 ; + } + printk(KERN_ERR KBUILD_MODNAME ": " "ERROR: Registers not mapped\n");
pr_err("ERROR: Registers not mapped\n");
etc...Review line 19
Quoted 2 lines
(quoted diff) +2
-0+ return -ENOSYS; +}
These are more commonly written as:
if (!fn_ptr) {
[ report_error_condition ]
return -ERRNO;
}
rtn = fn_ptr(foo);
if (rtn is err) {
[ report_error_condition ]
return -ERRNO2;
}
return 0;For more complicated styles where some unwinding
is necessary
if (!fn_ptr) {
[ report_error_condition ]
err = -ERRNO;
goto out;
}
windup
rtn = fn_ptr(foo);
if (rtn is err) {
[ report_error_condition ]
err = ERRNO2
goto out2;
}
return 0;outn:
.. out2: unwind; out: return err;
drivers/net/pch_gbe/pch_gbe_api.c line 132
Quoted 11 lines
drivers/net/pch_gbe/pch_gbe_api.c new file +11
-0+ +/** +* pch_gbe_hal_get_bus_info - Obtain bus information for adapter +* @hw: Pointer to the HW structure +*/ +inline void pch_gbe_hal_get_bus_info (struct pch_gbe_hw *hw) +{ +if (hw->func.get_bus_info) + hw->func.get_bus_info (hw); +else + printk(KERN_ERR KBUILD_MODNAME ": " "Error: configuration\n");
pr_err("ERROR: configuration\n");
etc...Review line 31
Quoted 1 line
(quoted diff) +1
-0+++ b/drivers/net/pch_gbe/pch_gbe_ethtool.c
[]
Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before any include
Review line 33
Quoted 2 lines
(quoted diff) +2
-0+#include <linux/pci.h> +#include <linux/ethtool.h>
[]
drivers/net/pch_gbe/pch_gbe_ethtool.c line 87
Quoted 7 lines
drivers/net/pch_gbe/pch_gbe_ethtool.c new file +7
-0+static int pch_gbe_get_settings (struct net_device *netdev, +struct ethtool_cmd *ecmd) +{ +struct pch_gbe_adapter *adapter =netdev_priv (netdev); +int ret; + +PCH_GBE_DEBUG ("ethtool: %s\n" , __func__);
If you really want to track entering functions,
it might be better to use something like:
#define FUNC_ENTER() pr_devel("ethtool: %s enter\n", __func__) #define FUNC_EXIT() pr_devel("ethtool: %s exit\n", __func__)
Unlike pr_debug, pr_devel does not remain active in code when DEBUG is not #defined. Look up dynamic_debug.
drivers/net/pch_gbe/pch_gbe_main.c line 111
Quoted 3 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +3
-0+PCH_GBE_DEBUG ("hw->mac.addr : 0x%02x %02x %02x %02x %02x %02x\n" , + hw->mac.addr[0 ], hw->mac.addr[1 ], hw->mac.addr[2 ], + hw->mac.addr[3 ], hw->mac.addr[4 ], hw->mac.addr[5 ]);
There's a vsprintf pointer extension "%pM" used for mac addresses
pr_debug("hw->mac.addr: %pM\n, hw->mac.addr);etc.
Quoted 11 lines · On Thu, 26 Aug 2010 18:56:55 +0900 Masayuki Ohtake <[email protected]>…
---
Gigabit Ethernet driver of Topcliff PCHTopcliff PCH is the platform controller hub that is going to be used in Intel's upcoming general embedded platform. All IO peripherals in Topcliff PCH are actually devices sitting on AMBA bus. Topcliff PCH has Gigabit Ethernet I/F. Using this I/F, it is able to access system devices connected to Gigabit Ethernet.
Signed-off-by Masayuki Ohtake <[email protected]>---
You can initialize your function table at compile time.
Quoted 25 lines
drivers/net/pch_gbe/pch_gbe.h new file +25
-0+ +struct pch_gbe_hw ; +/** +* struct pch_gbe_functions - HAL APi function pointer +* @get_bus_info: for pch_gbe_hal_get_bus_info +* @init_hw: for pch_gbe_hal_init_hw +* @read_phy_reg: for pch_gbe_hal_read_phy_reg +* @write_phy_reg: for pch_gbe_hal_write_phy_reg +* @reset_phy: for pch_gbe_hal_phy_hw_reset +* @sw_reset_phy: for pch_gbe_hal_phy_sw_reset +* @power_up_phy: for pch_gbe_hal_power_up_phy +* @power_down_phy: for pch_gbe_hal_power_down_phy +* @read_mac_addr: for pch_gbe_hal_read_mac_addr +*/ +struct pch_gbe_functions { +void (*get_bus_info) (struct pch_gbe_hw *); +s32 (*init_hw) (struct pch_gbe_hw *); +s32 (*read_phy_reg) (struct pch_gbe_hw *,u32 ,u16 *); +s32 (*write_phy_reg) (struct pch_gbe_hw *,u32 ,u16 ); +void (*reset_phy) (struct pch_gbe_hw *); +void (*sw_reset_phy) (struct pch_gbe_hw *); +void (*power_up_phy) (struct pch_gbe_hw *hw); +void (*power_down_phy) (struct pch_gbe_hw *hw); +s32 (*read_mac_addr) (struct pch_gbe_hw *); +};
...
drivers/net/pch_gbe/pch_gbe.h line 159
Quoted 13 lines
drivers/net/pch_gbe/pch_gbe.h new file +13
-0+ +/*! +* @ingroup Gigabit Ether driver Layer +* @struct pch_gbe_hw +* @brief Hardware infomation +*/ +struct pch_gbe_hw { +void *back; + +struct pch_gbe_regs __iomem *reg; +spinlock_t miim_lock; + +struct pch_gbe_functions func;
Should be:
const struct pch_gbe_functions *func;
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe.h new file +10
-0+struct pch_gbe_mac_info mac; +struct pch_gbe_phy_info phy; +struct pch_gbe_bus_info bus; + +u16 vendor_id; +u16 device_id; +u16 subsystem_vendor_id; +u16 subsystem_device_id; +u8 revision_id; +};
...
Quoted 75 lines
drivers/net/pch_gbe/pch_gbe_api.c new file +72
-0@@ -0,0 +1,247 @@ +/* +* Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD. +* +* 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; version 2 of the License. +* +* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "pch_gbe.h" +#include "pch_gbe_phy.h" + +/* bus type values */ +#define pch_gbe_bus_type_unknown 0 +#define pch_gbe_bus_type_pci 1 +#define pch_gbe_bus_type_pcix 2 +#define pch_gbe_bus_type_pci_express 3 +#define pch_gbe_bus_type_reserved 4 + +/* bus speed values */ +#define pch_gbe_bus_speed_unknown 0 +#define pch_gbe_bus_speed_33 1 +#define pch_gbe_bus_speed_66 2 +#define pch_gbe_bus_speed_100 3 +#define pch_gbe_bus_speed_120 4 +#define pch_gbe_bus_speed_133 5 +#define pch_gbe_bus_speed_2500 6 +#define pch_gbe_bus_speed_reserved 7 + +/* bus width values */ +#define pch_gbe_bus_width_unknown 0 +#define pch_gbe_bus_width_pcie_x1 1 +#define pch_gbe_bus_width_pcie_x2 2 +#define pch_gbe_bus_width_pcie_x4 4 +#define pch_gbe_bus_width_32 5 +#define pch_gbe_bus_width_64 6 +#define pch_gbe_bus_width_reserved 7 + +/** +* pch_gbe_plat_get_bus_info - Obtain bus information for adapter +* @hw: Pointer to the HW structure +*/ +static void pch_gbe_plat_get_bus_info (struct pch_gbe_hw *hw) +{ + hw->bus.type = pch_gbe_bus_type_pci_express; + hw->bus.speed = pch_gbe_bus_speed_2500; + hw->bus.width = pch_gbe_bus_width_pcie_x1; +} + +/** +* pch_gbe_plat_init_hw - Initialize hardware +* @hw: Pointer to the HW structure +* Returns +* 0: Successfully +* Negative value: Failed-EBUSY +*/ +static s32 pch_gbe_plat_init_hw (struct pch_gbe_hw *hw) +{ +s32 ret_val; + + ret_val =pch_gbe_phy_get_id (hw); +if (ret_val) { + printk(KERN_ERR KBUILD_MODNAME ": " + "pch_gbe_phy_get_id error\n");
drivers/net/pch_gbe/pch_gbe_api.c line 82
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_api.c new file +10
-0+return ret_val; + } +pch_gbe_phy_init_setting (hw); +/* Setup Mac interface option RGMII */ +#ifdef PCH_GBE_MAC_IFOP_RGMII +pch_gbe_phy_set_rgmii (hw); +#endif +return ret_val; +} +
static const struct pch_gbe_functions pch_gbe_ops = {
.get_bus_info = pch_gbe_plat_get_bus_info, .init_hw = pch_gbe_plat_init_hw, .read_phy_reg = pch_gbe_phy_read_reg_miic, .write_phy_reg = pch_gbe_phy_write_reg_miic, .reset_phy = pch_gbe_phy_hw_reset, .sw_reset_phy = pch_gbe_phy_sw_reset, .power_up_phy = pch_gbe_phy_power_up, .power_down_phy = pch_gbe_phy_power_down, .read_mac_addr = pch_gbe_mac_read_mac_addr,
};
drivers/net/pch_gbe/pch_gbe_api.c line 90
Quoted 8 lines
drivers/net/pch_gbe/pch_gbe_api.c new file +8
-0+/** +* pch_gbe_plat_init_function_pointers - Init func ptrs +* @hw: Pointer to the HW structure +*/ +void pch_gbe_plat_init_function_pointers (struct pch_gbe_hw *hw) +{ +struct pch_gbe_phy_info *phy = &hw->phy; +struct pch_gbe_functions *func = &hw->func;
const struct pch_gbe_functions *func = &hw->func;
drivers/net/pch_gbe/pch_gbe_api.c line 93
Quoted 3 lines
drivers/net/pch_gbe/pch_gbe_api.c new file +3
-0+ +/* Set PHY parameter */ + phy->reset_delay_us =PCH_GBE_PHY_RESET_DELAY_US ;
func = &pch_gbe_ops; (Don't init at run time)
Quoted 1 line
drivers/net/pch_gbe/pch_gbe_api.c new file +1
-0+}
Quoted 12 lines · On Thu, 26 Aug 2010 18:56:55 +0900 Masayuki Ohtake <[email protected]>…
drivers/net/pch_gbe/pch_gbe_ethtool.c new file +12
-0+static int pch_gbe_get_settings (struct net_device *netdev, +struct ethtool_cmd *ecmd) +{ +struct pch_gbe_adapter *adapter =netdev_priv (netdev); +int ret; + +PCH_GBE_DEBUG ("ethtool: %s\n" , __func__); + + ret =mii_ethtool_gset (&adapter->mii, ecmd); + ecmd->supported &= (u32) (~SUPPORTED_TP ); + ecmd->supported &= (u32) (~SUPPORTED_1000baseT_Half); + ecmd->advertising &= (u32) (~ADVERTISED_TP );
drivers/net/pch_gbe/pch_gbe_ethtool.c line 102
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_ethtool.c new file +10
-0+ ecmd->advertising &= (u32) (~ADVERTISED_1000baseT_Half); + +if (netif_carrier_ok (adapter->netdev)) { + ; + }else { + ecmd->speed =0xFFFF ; + ecmd->duplex =0xFF ; + } +return ret; +}
No need for cast to u32 on the masking:
ecmd->supported &= ~(SUPPORTED_TP | SUPPORTED_1000baseT_Half); ecmd->advertising &= ~(ADVERTISED_TP | ADVERTISED_1000baseT_Half);
Awkward use of if, and don't set other bits in duplex
if (!netif_carrier_ok(adapter->netdev))
ecmd->speed = -1;Quoted 10 lines · On Thu, 26 Aug 2010 18:56:55 +0900 Masayuki Ohtake <[email protected]>…
drivers/net/pch_gbe/pch_gbe_ethtool.c new file +10
-0+ +/** +* pch_gbe_set_settings - Set device-specific settings +* @netdev: Network interface device structure +* @ecmd: Ethtool command +* Returns +* 0: Successful. +* Negative value: Failed. +*/ +static int pch_gbe_set_settings(struct net_device *netdev,
drivers/net/pch_gbe/pch_gbe_ethtool.c line 122
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_ethtool.c new file +10
-0+ struct ethtool_cmd *ecmd) +{ +struct pch_gbe_adapter *adapter =netdev_priv (netdev); +struct pch_gbe_hw *hw = &adapter->hw; +int ret; + +PCH_GBE_DEBUG ("ethtool: %s\n" , __func__); + +while (test_and_set_bit (__PCH_GBE_RESETTING, &adapter->flags)) +msleep (1 );
Don't invent your own mutex mechanism. Either use spin lock or mutex.
Quoted 14 lines · On Thu, 26 Aug 2010 18:56:55 +0900 Masayuki Ohtake <[email protected]>…
drivers/net/pch_gbe/pch_gbe_ethtool.c new file +14
-0+ +static struct ethtool_ops pch_gbe_ethtool_ops = { + .get_settings = pch_gbe_get_settings, + .set_settings = pch_gbe_set_settings, + .get_drvinfo = pch_gbe_get_drvinfo, + .get_regs_len = pch_gbe_get_regs_len, + .get_regs = pch_gbe_get_regs, + .get_wol = pch_gbe_get_wol, + .set_wol = pch_gbe_set_wol, + .nway_reset = pch_gbe_nway_reset, + .get_link = ethtool_op_get_link, + .get_ringparam = pch_gbe_get_ringparam, + .set_ringparam = pch_gbe_set_ringparam, + .get_pauseparam = pch_gbe_get_pauseparam,
drivers/net/pch_gbe/pch_gbe_ethtool.c line 617
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_ethtool.c new file +10
-0+ .set_pauseparam = pch_gbe_set_pauseparam, + .get_rx_csum = pch_gbe_get_rx_csum, + .set_rx_csum = pch_gbe_set_rx_csum, + .get_tx_csum = pch_gbe_get_tx_csum, + .set_tx_csum = pch_gbe_set_tx_csum, + .get_strings = pch_gbe_get_strings, + .get_ethtool_stats = pch_gbe_get_ethtool_stats, + .get_sset_count = pch_gbe_get_sset_count, +}; +
Should be const
Quoted 9 lines · On Thu, 26 Aug 2010 18:56:55 +0900 Masayuki Ohtake <[email protected]>…
s32
pch_gbe_mac_read_mac_addr(struct pch_gbe_hw *hw)drivers/net/pch_gbe/pch_gbe_main.c new file +8
-0+{ +u32 adr1a, adr1b; + +PCH_GBE_DEBUG ("pch_gbe_mac_read_mac_addr\n" ); + + adr1a =ioread32 (&hw->reg->mac_adr[0 ].high); + adr1b =ioread32 (&hw->reg->mac_adr[0 ].low); +
drivers/net/pch_gbe/pch_gbe_main.c line 111
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +10
-0+ hw->mac.addr[0 ] = (u8)(adr1a &0xFF ); + hw->mac.addr[1 ] = (u8)((adr1a >>8 ) &0xFF ); + hw->mac.addr[2 ] = (u8)((adr1a >>16 ) &0xFF ); + hw->mac.addr[3 ] = (u8)((adr1a >>24 ) &0xFF ); + hw->mac.addr[4 ] = (u8)(adr1b &0xFF ); + hw->mac.addr[5 ] = (u8)((adr1b >>8 ) &0xFF ); + +PCH_GBE_DEBUG ("hw->mac.addr : 0x%02x %02x %02x %02x %02x %02x\n" , + hw->mac.addr[0 ], hw->mac.addr[1 ], hw->mac.addr[2 ], + hw->mac.addr[3 ], hw->mac.addr[4 ], hw->mac.addr[5 ]);
can use new %pM printk format here.
Quoted 14 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +13
-0+/** +* pch_gbe_mac_init_rx_addrs - Initialize receive address's +* @hw: Pointer to the HW structure +* @mar_count: Receive address registers +*/ +void pch_gbe_mac_init_rx_addrs (struct pch_gbe_hw *hw,u16 mar_count) +{ +u32 i; +PCH_GBE_DEBUG ("pch_gbe_mac_init_rx_addrs\n" ); + +/* Setup the receive address */ +pch_gbe_mac_mar_set (hw, hw->mac.addr,0 ); +
drivers/net/pch_gbe/pch_gbe_main.c line 200
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +10
-0+/* Zero out the other receive addresses */ +for (i =1 ; i < mar_count; i++) { +iowrite32 (0 , &hw->reg->mac_adr[i].high); +iowrite32 (0 , &hw->reg->mac_adr[i].low); + } +iowrite32 (0xFFFE , &hw->reg->ADDR_MASK); +/* wait busy */ +while ((ioread32 (&hw->reg->ADDR_MASK) &PCH_GBE_BUSY )) + ; +}
Use cpu_relax here to allow other hyper-thread to run.
/* wait busy */ while ((ioread32(&hw->reg->ADDR_MASK) & PCH_GBE_BUSY)) cpu_relax();
Quoted 24 lines · On Thu, 26 Aug 2010 18:56:55 +0900 Masayuki Ohtake <[email protected]>…
drivers/net/pch_gbe/pch_gbe_main.c new file +24
-0+/** +* pch_gbe_alloc_queues - Allocate memory for all rings +* @adapter: Board private structure to initialize +* Returns +* 0: Successfully +* Negative value: Failed +*/ +static int pch_gbe_alloc_queues (struct pch_gbe_adapter *adapter) +{ +int size; + +PCH_GBE_DEBUG ("%s\n" , __func__); + + + size = (int )sizeof (struct pch_gbe_tx_ring ); + adapter->tx_ring =kmalloc (size,GFP_KERNEL ); +if (!adapter->tx_ring) +return -ENOMEM ; +memset (adapter->tx_ring,0 , size); + + size = (int )sizeof (struct pch_gbe_rx_ring ); + adapter->rx_ring =kmalloc (size,GFP_KERNEL ); +if (!adapter->rx_ring) { +kfree (adapter->tx_ring);
drivers/net/pch_gbe/pch_gbe_main.c line 440
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +10
-0+return -ENOMEM ; + } +memset (adapter->rx_ring,0 , size); + + size = (int )sizeof (struct net_device ); + adapter->polling_netdev =kmalloc (size,GFP_KERNEL ); +if (!adapter->polling_netdev) { +kfree (adapter->tx_ring); +kfree (adapter->rx_ring); +return -ENOMEM ;
This is not allowed, you can not just allocate up a network device structure out of kmalloc space. Not sure what you are doing with the polling_netdev? Is it left over from when net_device and NAPI were more closely bound?
Quoted 50 lines · On Thu, 26 Aug 2010 18:56:55 +0900 Masayuki Ohtake <[email protected]>…
drivers/net/pch_gbe/pch_gbe_main.c new file +50
-0+static void pch_gbe_tx_queue (struct pch_gbe_adapter *adapter, +struct pch_gbe_tx_ring *tx_ring,struct sk_buff *skb) +{ +struct pch_gbe_hw *hw = &adapter->hw; +struct pch_gbe_tx_desc *tx_desc; +struct pch_gbe_buffer *buffer_info; +struct sk_buff *tmp_skb; +unsigned int frame_ctrl; +unsigned int ring_num; +unsigned long flags; + +PCH_GBE_DEBUG ("%s\n" , __func__); + + +/*-- Set frame control --*/ + frame_ctrl =0 ; +if (unlikely (skb->len <PCH_GBE_SHORT_PKT )) + frame_ctrl |=PCH_GBE_TXD_CTRL_APAD ; +if (unlikely (adapter->tx_csum == FALSE)) + frame_ctrl |=PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF ; + +/* Performs checksum processing */ +/* +* It is because the hardware accelerator does not support a checksum, +* when the received data size is less than 64 bytes. +*/ +if ((skb->len <PCH_GBE_SHORT_PKT ) && (adapter->tx_csum == TRUE)) { + frame_ctrl |= +PCH_GBE_TXD_CTRL_APAD |PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF ; +if (skb->protocol ==htons (ETH_P_IP )) { +struct iphdr *iph =ip_hdr (skb); +unsigned int offset; + iph->check =0 ; + iph->check =ip_fast_csum ((u8 *) iph, iph->ihl); + offset =skb_transport_offset (skb); +if (iph->protocol ==IPPROTO_TCP ) { + skb->csum =0 ; +tcp_hdr (skb)->check =0 ; + skb->csum = +skb_checksum (skb, offset, + skb->len - offset,0 ); +tcp_hdr (skb)->check = +csum_tcpudp_magic (iph->saddr, + iph->daddr, + skb->len - offset, +IPPROTO_TCP , skb->csum); + }else if (iph->protocol ==IPPROTO_UDP ) { + skb->csum =0 ; +udp_hdr (skb)->check =0 ; + skb->csum =
drivers/net/pch_gbe/pch_gbe_main.c line 1073
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +10
-0+skb_checksum (skb, offset, + skb->len - offset,0 ); +udp_hdr (skb)->check = +csum_tcpudp_magic (iph->saddr, + iph->daddr, + skb->len - offset, +IPPROTO_UDP , skb->csum); + } + } + }
Why not something simpler using skb_checksum_help which is safer since it handles case of shared skb correctly.
if (skb->ip_summed = CHECKSUM_COMPLETE &&
skb->len < PCH_GBE_SHORT_PKT) {
frame_ctrl |=
PCH_GBE_TXD_CTRL_APAD | PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF;
skb->ip_summed = CHECKSUM_NONE;
if (skb_checksum_help(skb))
goto drop; /* could not expand header to find space */
}+static int pch_gbe_probe(struct pci_dev *pdev,
+ const struct pci_device_id *pci_id)
+{
+ struct net_device *netdev;
+ struct pch_gbe_adapter *adapter;
+ unsigned long mmio_start;
+ unsigned long mmio_len;
+ int i, ret;
+
+ PCH_GBE_DEBUG("pch_gbe_probe\n");
+ ret = pci_enable_device(pdev);
+ if (ret)
+ return ret;
+
+ if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))
+ && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
+ ;
+ } else {
+ ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
+ if (ret) {
+ ret = dma_set_coherent_mask(&pdev->dev,
+ DMA_BIT_MASK(32));
+ if (ret) {
+ printk(KERN_ERR KBUILD_MODNAME ": ERR: "
+ "No usable DMA configuration, aborting\n");
+ goto err_disable_device;
+ }
+ }
+ }
+ ret = pci_request_regions(pdev, KBUILD_MODNAME);
+ if (ret) {
+ printk(KERN_ERR KBUILD_MODNAME ": "
+ "ERR: Can't reserve PCI I/O and memory resources\n");
+ goto err_disable_device;
+ }
+ pci_set_master(pdev);
+
+ netdev = alloc_etherdev((int)sizeof(struct pch_gbe_adapter));
+ if (!netdev) {
+ ret = -ENOMEM;
+ printk(KERN_ERR KBUILD_MODNAME ": "
+ "ERR: Can't allocates and sets up an Ethernet device\n");
+ goto err_release_pci;
+ }
+ SET_NETDEV_DEV(netdev, &pdev->dev);
+
+ pci_set_drvdata(pdev, netdev);
+ adapter = netdev_priv(netdev);
+ adapter->netdev = netdev;
+ adapter->pdev = pdev;
+ adapter->hw.back = adapter;
+ mmio_start = pci_resource_start(pdev, PCH_GBE_PCI_BAR);
+ mmio_len = pci_resource_len(pdev, PCH_GBE_PCI_BAR);
+ adapter->hw.reg = ioremap_nocache(mmio_start, mmio_len);
+ if (!adapter->hw.reg) {
+ ret = -EIO;
+ printk(KERN_ERR KBUILD_MODNAME ": " "Can't ioremap\n");
+ goto err_free_netdev;
+ }
+
+ netdev->netdev_ops = &pch_gbe_netdev_ops;
+ netdev->watchdog_timeo = PCH_GBE_WATCHDOG_PERIOD;
+ netif_napi_add(netdev, &adapter->napi,
+ pch_gbe_napi_poll, PCH_GBE_RX_WEIGHT);
+ strncpy(netdev->name, pci_name(pdev), (int)sizeof(netdev->name) - 1);
+ netdev->mem_start = mmio_start;
+ netdev->mem_end = mmio_start + mmio_len;
+ netdev->features = NETIF_F_HW_CSUM;
+ pch_gbe_set_ethtool_ops(netdev);
+
+ pch_gbe_mac_reset_hw(&adapter->hw);
+
+ /* setup the private structure */
+ ret = pch_gbe_sw_init(adapter);
+ if (ret)
+ goto err_iounmap;
+
+ /* Initialize PHY */
+ ret = pch_gbe_init_phy(adapter);
+ if (ret) {
+ printk(KERN_ERR KBUILD_MODNAME ": " "PHY initialize error\n");
+ goto err_free_adapter;
+ }
+ pch_gbe_hal_get_bus_info(&adapter->hw);
+
+ /* Read the MAC address. and store to the private data */
+ ret = pch_gbe_hal_read_mac_addr(&adapter->hw);
+ if (ret) {
+ printk(KERN_ERR KBUILD_MODNAME ": " "MAC address Read Error\n");
+ goto err_free_adapter;
+ }
+
+ memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
+ if (!is_valid_ether_addr(netdev->dev_addr)) {
+ printk(KERN_ERR KBUILD_MODNAME ": " "Invalid MAC Address\n");
+ ret = -EIO;
+ goto err_free_adapter;
+ }
+
+ init_timer(&adapter->watchdog_timer);
+ adapter->watchdog_timer.function = &pch_gbe_watchdog;
+ adapter->watchdog_timer.data = (unsigned long)adapter;
+
+ INIT_WORK(&adapter->reset_task, pch_gbe_reset_task);
+
+ pch_gbe_check_options(adapter);
+
+ if (adapter->tx_csum)
+ netdev->features |= NETIF_F_HW_CSUM;
+ else
+ netdev->features &= ~NETIF_F_HW_CSUM;
+
+ /* initialize the wol settings based on the eeprom settings */
+ adapter->wake_up_evt = PCH_GBE_WL_INIT_SETTING;
+ for (i = 0; i < 6; i++)
+ printk(KERN_INFO "%2.2x%c",
+ netdev->dev_addr[i], i == 5 ? '\n' : ':');
This is wrong since it produces KERN_INFO tag without newline, and probably you just want:
printk(KERN_INFO "%pM", netdev->dev_addr);
or better yet, convert to dev_printk
+
+ /* reset the hardware with the new settings */
+ pch_gbe_reset(adapter);
+
+ strcpy(netdev->name, "eth%d");
This is unnecessary since you used alloc_etherdev()
+ ret = register_netdev(netdev);
+ if (ret)
+ goto err_free_adapter;
+ /* tell the stack to leave us alone until pch_gbe_open() is called */
+ netif_carrier_off(netdev);
+ netif_stop_queue(netdev);
+
+ PCH_GBE_DEBUG("OKIsemi(R) PCH Network Connection\n");
+
+ device_set_wakeup_enable(&pdev->dev, 1);
+ return 0;
+
+err_free_adapter:
+ pch_gbe_hal_phy_hw_reset(&adapter->hw);
+ dev_put(adapter->polling_netdev);
+ kfree(adapter->tx_ring);
+ kfree(adapter->rx_ring);
+ kfree(adapter->polling_netdev);
+err_iounmap:
+ iounmap(adapter->hw.reg);
+err_free_netdev:
+ free_netdev(netdev);
+err_release_pci:
+ pci_release_regions(pdev);
+err_disable_device:
+ pci_disable_device(pdev);
+ return ret;
+}
Quoted 8 lines · Stephen Hemminger
drivers/net/pch_gbe/pch_gbe_main.c new file +3
-0+for (i =0 ; i <6 ; i++) +printk (KERN_INFO "%2.2x%c" , + netdev->dev_addr[i], i ==5 ?'\n' :':' );you just want:
printk(KERN_INFO "%pM", netdev->dev_addr);or better yet, convert to
dev_printk
or perhaps better still convert to netdev_info
My message logging order preference:
if there's a netif_msg_<type> and a struct net_device
netif_<level> (struct private *, netif_msg_<type>, struct net_device *, fmt, args...) if there's a struct net_device netdev_<level> (struct net_device *, fmt, args...) if there's a struct device dev_<level> (struct device *, fmt, args...) otherwise pr_<level> (fmt, args...)
Quoted 15 lines · On Thu, 26 Aug 2010 09:16:12 -0700 Joe Perches <[email protected]> wrote:
Quoted 8 lines · Stephen Hemminger
drivers/net/pch_gbe/pch_gbe_main.c new file +3
-0+for (i =0 ; i <6 ; i++) +printk (KERN_INFO "%2.2x%c" , + netdev->dev_addr[i], i ==5 ?'\n' :':' );you just want:
printk(KERN_INFO "%pM", netdev->dev_addr);or better yet, convert to
dev_printkor perhaps better still convert to
netdev_infoMy message logging order preference:
if there's a netif_msg_<type> and a struct
net_device
Quoted 10 lines
netif_<level> (struct private *, netif_msg_<type>, struct net_device *, fmt, args...) if there's a struct net_device netdev_<level> (struct net_device *, fmt, args...) if there's a struct device dev_<level> (struct device *, fmt, args...) otherwise pr_<level> (fmt, args...)
At this point in process, netdevice isn't registered so it doesn't have a ethX name. so dev_info would be best.
Quoted 12 lines · Stephen Hemminger
Quoted 10 lines · On Thu, 26 Aug 2010 09:16:12 -0700 Joe Perches <[email protected]> wrote:
My message logging order preference:
if there's a netif_msg_<type> and a structnet_devicenetif_<level> (struct private *, netif_msg_<type>, struct net_device *, fmt, args...) if there's a struct net_device netdev_<level> (struct net_device *, fmt, args...) if there's a struct device dev_<level> (struct device *, fmt, args...) otherwise pr_<level> (fmt, args...)
Quoted 2 lines
At this point in process, netdevice isn't registered so it doesn't have a ethX name. so
dev_infowould be best.
Yes, likely true.
Ideally netdev_<level> is used after register_netdev. The default "eth%d" is printed after alloc_netdev but before register_netdev.
Before commmit 256df2f3879efdb2e9808bdb1b54b16fbb11fa38 when netdev_<level>s were converted to functions, they would also dereference a NULL pointer if used before register_netdev.
PATCH 1/1 Gigabit Ethernet driver of Topcliff PCH
In reply to Masayuki OhtakeHi Sam, Joe and Stephen
Thank you for your comments.
We have modified this driver for your comment.
---
Gigabit Ethernet driver of Topcliff PCH
Patch created against 2.6.35
Topcliff PCH is the platform controller hub that is going to be used in Intel's upcoming general embedded platform. All IO peripherals in Topcliff PCH are actually devices sitting on AMBA bus. Topcliff PCH has Gigabit Ethernet I/F. Using this I/F, it is able to access system devices connected to Gigabit Ethernet.
--- drivers/net/Kconfig | 10 + drivers/net/Makefile | 1 + drivers/net/pch_gbe/Makefile | 4 + drivers/net/pch_gbe/pch_gbe.h | 683 +++++++++ drivers/net/pch_gbe/pch_gbe_api.c | 246 ++++ drivers/net/pch_gbe/pch_gbe_api.h | 34 + drivers/net/pch_gbe/pch_gbe_ethtool.c | 618 ++++++++ drivers/net/pch_gbe/pch_gbe_main.c | 2591 +++++++++++++++++++++++++++++++++ drivers/net/pch_gbe/pch_gbe_param.c | 519 +++++++ drivers/net/pch_gbe/pch_gbe_phy.c | 276 ++++ drivers/net/pch_gbe/pch_gbe_phy.h | 35 + 11 files changed, 5017 insertions(+), 0 deletions(-) create mode 100644 drivers/net/pch_gbe/Makefile create mode 100644 drivers/net/pch_gbe/pch_gbe.h create mode 100644 drivers/net/pch_gbe/pch_gbe_api.c create mode 100644 drivers/net/pch_gbe/pch_gbe_api.h create mode 100644 drivers/net/pch_gbe/pch_gbe_ethtool.c create mode 100644 drivers/net/pch_gbe/pch_gbe_main.c create mode 100644 drivers/net/pch_gbe/pch_gbe_param.c create mode 100644 drivers/net/pch_gbe/pch_gbe_phy.c create mode 100644 drivers/net/pch_gbe/pch_gbe_phy.h
drivers/net/Kconfig +10 -0
@@ -2004,6 +2004,16 @@ menuconfig NETDEV_1000 If you say N, all options in this submenu will be skipped and disabled. if NETDEV_1000 +config PCH_GBE + tristate "PCH Gigabit Ethernet" + depends on PCI + ---help--- + This is an gigabit ethernet driver for Topcliff PCH. + Topcliff PCH is the platform controller hub that is going to be used + in Intel's upcoming general embedded platform. + Topcliff PCH has Gigabit Ethernet I/F. Using this I/F, it is able to + access system devices connected to Gigabit Ethernet. + This driver enables Gigabit Ethernet function. config ACENIC tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support"
drivers/net/Makefile +1 -0
@@ -295,3 +295,4 @@ obj-$(CONFIG_WIMAX) += wimax/ obj-$(CONFIG_CAIF) += caif/ obj-$(CONFIG_OCTEON_MGMT_ETHERNET) += octeon/ +obj-$(CONFIG_PCH_GBE) += pch_gbe/
drivers/net/pch_gbe/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +obj-$(CONFIG_PCH_GBE) += pch_gbe.o +//EXTRA_CFLAGS += -DDEBUG +pch_gbe-y := pch_gbe_phy.o pch_gbe_ethtool.o pch_gbe_param.o +pch_gbe-y += pch_gbe_api.o pch_gbe_main.o
drivers/net/pch_gbe/pch_gbe.h new file +683 -0
683 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_api.c new file +246 -0
246 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_api.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (C) 1999 - 2010 Intel Corporation. +* Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD. +* +* This code was derived from the Intel e1000e Linux driver. +* +* 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; version 2 of the License. +* +* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef _PCH_GBE_API_H_ +#define _PCH_GBE_API_H_ + +s32 pch_gbe_hal_setup_init_funcs (struct pch_gbe_hw *hw); +void pch_gbe_hal_get_bus_info (struct pch_gbe_hw *hw); +s32 pch_gbe_hal_init_hw (struct pch_gbe_hw *hw); +s32 pch_gbe_hal_read_phy_reg (struct pch_gbe_hw *hw,u32 offset,u16 *data); +s32 pch_gbe_hal_write_phy_reg (struct pch_gbe_hw *hw,u32 offset,u16 data); +void pch_gbe_hal_phy_hw_reset (struct pch_gbe_hw *hw); +void pch_gbe_hal_phy_sw_reset (struct pch_gbe_hw *hw); +s32 pch_gbe_hal_read_mac_addr (struct pch_gbe_hw *hw); +void pch_gbe_hal_power_up_phy (struct pch_gbe_hw *hw); +void pch_gbe_hal_power_down_phy (struct pch_gbe_hw *hw); + +#endif
drivers/net/pch_gbe/pch_gbe_ethtool.c new file +618 -0
618 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_main.c new file +2591 -0
1,395 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_param.c new file +519 -0
519 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_phy.c new file +276 -0
276 lines not on this page · raw message
drivers/net/pch_gbe/pch_gbe_phy.h new file +35 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.2.5
Part of the diff is not shown here. View the raw message.
Quoted 8 lines · Masayuki Ohtake
Hi Sam, Joe and Stephen
Thank you for your comments.
We have modified this driver for your comment.---
Gigabit Ethernet driver of Topcliff PCH
drivers/net/pch_gbe/pch_gbe_main.c line 1526
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +10
-0+ skb->protocol =eth_type_trans (skb, netdev); +if ((tcp_ip_status &PCH_GBE_RXD_ACC_STAT_TCPIPOK ) == +PCH_GBE_RXD_ACC_STAT_TCPIPOK ) { + skb->ip_summed =CHECKSUM_UNNECESSARY ; + }else { + skb->ip_summed =CHECKSUM_NONE ; + } + +if (netif_receive_skb (skb) ==NET_RX_DROP ) { + adapter->stats.rx_dropped++;
dont use pr_err() here, dropping a frame is a normal condition.
drivers/net/pch_gbe/pch_gbe_main.c line 1530
Quoted 4 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +4
-0+pr_err ("Receive Netif Receive Dropped Error\n" ); + } + (*work_done)++; + netdev->last_rx = jiffies;
really ? last_rx is a thing of the past.
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +10
-0+pr_debug + ("Receive skb->ip_summed: %d length: %d\n" , + skb->ip_summed, length); + } +dorrop: +/* return some buffers to hardware, one at a time is too slow */ +if (unlikely (cleaned_count >=PCH_GBE_RX_BUFFER_WRITE )) { +pch_gbe_alloc_rx_buffers (adapter, rx_ring, + cleaned_count); + cleaned_count =0 ;
drivers/net/pch_gbe/pch_gbe_main.c line 1550
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +10
-0+ } +if (++i == rx_ring->count) + i =0 ; + } + rx_ring->next_to_clean = i; +if (cleaned_count) +pch_gbe_alloc_rx_buffers (adapter, rx_ring, cleaned_count); +return cleaned; +} +
I find hard to believe this driver needs to copy all outgoing frames on pre-allocated skbs.
+ /* [Header:14][payload] ---> [Header:14][paddong:2][payload] */ + memcpy(tmp_skb->data, skb->data, ETH_HLEN); + tmp_skb->data[ETH_HLEN] = 0x00; + tmp_skb->data[ETH_HLEN + 1] = 0x00; + tmp_skb->len = skb->len; + memcpy(&tmp_skb->data[ETH_HLEN + 2], &skb->data[ETH_HLEN],
+ (skb->len - ETH_HLEN));
+ buffer_info->kernel_skb = skb;
+ skb = tmp_skb;
Whats the deal here please ?
Hi Eric
Thank you for your comments.
Quoted 13 lines
I find hard to believe this driver needs to copy all outgoing frames on pre-allocated skbs.
drivers/net/pch_gbe/pch_gbe_main.c new file +9
-0+/* [Header:14][payload] ---> [Header:14][paddong:2][payload] */ +memcpy (tmp_skb->data, skb->data,ETH_HLEN ); + tmp_skb->data[ETH_HLEN ] =0x00 ; + tmp_skb->data[ETH_HLEN +1 ] =0x00 ; + tmp_skb->len = skb->len; +memcpy (&tmp_skb->data[ETH_HLEN +2 ], &skb->data[ETH_HLEN ], + (skb->len -ETH_HLEN )); + buffer_info->kernel_skb = skb; + skb = tmp_skb;
Quoted 1 line
Whats the deal here please ?
This processing depends on hardware specification.
At the time of transmission.
Hardware accepts a packet in the following format.
[Header: 14octet] + [padding: 2octet] + [payload]
Also, it is necessary to align the head of a [Header: 14octet] at 64byte.
In my knowledge, SKB received by kernel are the following format.
[padding: 2octet] + [Header:14octet] + [payload] Also, The head of [payload] has aligned at 16 byte.
So, it has adjusted with the format of hardware by a copy.
Thanks, Ohtake(OKISemi)
----- Original Message -----
From: "Eric Dumazet" <[email protected]>
To: "Masayuki Ohtake" <[email protected]>
Cc: "Stephen Hemminger" <[email protected]>; "Sam Ravnborg" <[email protected]>; "Joe Perches" <[email protected]>; "LKML" <[email protected]>; "ML netdev" <[email protected]>; "Greg Rose" <[email protected]>; "Maxime Bizon" <[email protected]>; "Kristoffer Glembo" <[email protected]>; "Ralf Baechle" <[email protected]>; "John Linn" <[email protected]>; "Randy Dunlap" <[email protected]>; "David S. Miller" <[email protected]>; "MeeGo" <[email protected]>; "Wang, Qi" <[email protected]>; "Wang, Yong Y" <[email protected]>; "Andrew" <[email protected]>; "Intel OTC" <[email protected]>; "Foster, Margie" <[email protected]>; "Toshiharu Okada" <[email protected]>; "Tomoya Morinaga" <[email protected]>; "Takahiro Shimizu" <[email protected]>
Sent: Tuesday, August 31, 2010 11:51 PM
Subject: Re: [PATCH] Gigabit Ethernet driver of Topcliff PCH
Quoted 73 lines
Le mardi 31 aout 2010 a 23:15 +0900, Masayuki Ohtake a ecrit :
Quoted 10 lines
Hi Sam, Joe and Stephen
Thank you for your comments.
We have modified this driver for your comment.---
Gigabit Ethernet driver of Topcliff PCH+
skb->protocol=eth_type_trans(skb, netdev);
+ if ((tcp_ip_status&PCH_GBE_RXD_ACC_STAT_TCPIPOK) ==drivers/net/pch_gbe/pch_gbe_main.c line 1526
Quoted 8 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +8
-0+ PCH_GBE_RXD_ACC_STAT_TCPIPOK) { + skb->ip_summed = CHECKSUM_UNNECESSARY; + } else { + skb->ip_summed =CHECKSUM_NONE ; + } + +if (netif_receive_skb (skb) ==NET_RX_DROP ) { + adapter->stats.rx_dropped++;dont use
pr_err()here, dropping a frame is a normal condition.Quoted 4 lines
+
pr_err("Receive Netif Receive Dropped Error\n");
+ }
+ (*work_done)++;
+netdev->last_rx= jiffies;really ?
last_rxis a thing of the past.Quoted 10 lines
+
pr_debugdrivers/net/pch_gbe/pch_gbe_main.c new file +9
-0+ ("Receive skb->ip_summed: %d length: %d\n" , + skb->ip_summed, length); + } +dorrop: +/* return some buffers to hardware, one at a time is too slow */ +if (unlikely (cleaned_count >=PCH_GBE_RX_BUFFER_WRITE )) { +pch_gbe_alloc_rx_buffers (adapter, rx_ring, + cleaned_count); + cleaned_count =0 ;drivers/net/pch_gbe/pch_gbe_main.c line 1550
Quoted 10 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +10
-0+ } +if (++i == rx_ring->count) + i =0 ; + } + rx_ring->next_to_clean = i; +if (cleaned_count) +pch_gbe_alloc_rx_buffers (adapter, rx_ring, cleaned_count); +return cleaned; +} +I find hard to believe this driver needs to copy all outgoing frames on pre-allocated skbs.
drivers/net/pch_gbe/pch_gbe_main.c new file +9
-0+/* [Header:14][payload] ---> [Header:14][paddong:2][payload] */ +memcpy (tmp_skb->data, skb->data,ETH_HLEN ); + tmp_skb->data[ETH_HLEN ] =0x00 ; + tmp_skb->data[ETH_HLEN +1 ] =0x00 ; + tmp_skb->len = skb->len; +memcpy (&tmp_skb->data[ETH_HLEN +2 ], &skb->data[ETH_HLEN ], + (skb->len -ETH_HLEN )); + buffer_info->kernel_skb = skb; + skb = tmp_skb;Whats the deal here please ?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 26 lines · Masayuki Ohtake
Hi Eric
Thank you for your comments.
Quoted 13 lines
I find hard to believe this driver needs to copy all outgoing frames on pre-allocated skbs.
drivers/net/pch_gbe/pch_gbe_main.c new file +9
-0+/* [Header:14][payload] ---> [Header:14][paddong:2][payload] */ +memcpy (tmp_skb->data, skb->data,ETH_HLEN ); + tmp_skb->data[ETH_HLEN ] =0x00 ; + tmp_skb->data[ETH_HLEN +1 ] =0x00 ; + tmp_skb->len = skb->len; +memcpy (&tmp_skb->data[ETH_HLEN +2 ], &skb->data[ETH_HLEN ], + (skb->len -ETH_HLEN )); + buffer_info->kernel_skb = skb; + skb = tmp_skb;Quoted 1 line
Whats the deal here please ?
This processing depends on hardware specification.
At the time of transmission.
Hardware accepts a packet in the following format.
[Header: 14octet] + [padding: 2octet] + [payload]
Also, it is necessary to align the head of a [Header: 14octet] at 64byte.
Quoted 5 lines
In my knowledge, SKB received by kernel are the following format.
[padding: 2octet] + [Header:14octet] + [payload] Also, The head of [payload] has aligned at 16 byte.So, it has adjusted with the format of hardware by a copy.
The two bytes padding can be handled by network stack, if you force in your setup phase :
dev->hard_header_len = ETH_HLEN + 2;
then, you can do a single memcpy:
memcpy(tmp_skb->data, skb->data, skb->len);
About the 64 byte alignement, it might be a bit more complex :)
Quoted 35 lines · On Thu, 02 Sep 2010 15:40:47 +0200 Eric Dumazet <[email protected]> wrote:
Quoted 26 lines · Masayuki Ohtake
Hi Eric
Thank you for your comments.
Quoted 13 lines
I find hard to believe this driver needs to copy all outgoing frames on pre-allocated skbs.
drivers/net/pch_gbe/pch_gbe_main.c new file +9
-0+/* [Header:14][payload] ---> [Header:14][paddong:2][payload] */ +memcpy (tmp_skb->data, skb->data,ETH_HLEN ); + tmp_skb->data[ETH_HLEN ] =0x00 ; + tmp_skb->data[ETH_HLEN +1 ] =0x00 ; + tmp_skb->len = skb->len; +memcpy (&tmp_skb->data[ETH_HLEN +2 ], &skb->data[ETH_HLEN ], + (skb->len -ETH_HLEN )); + buffer_info->kernel_skb = skb; + skb = tmp_skb;Quoted 1 line
Whats the deal here please ?
This processing depends on hardware specification.
At the time of transmission.
Hardware accepts a packet in the following format.
[Header: 14octet] + [padding: 2octet] + [payload]
Also, it is necessary to align the head of a [Header: 14octet] at 64byte.Quoted 5 lines
In my knowledge, SKB received by kernel are the following format.
[padding: 2octet] + [Header:14octet] + [payload] Also, The head of [payload] has aligned at 16 byte.So, it has adjusted with the format of hardware by a copy.
The two bytes padding can be handled by network stack, if you force in your setup phase :
Quoted 7 lines
dev->hard_header_len = ETH_HLEN + 2;then, you can do a single memcpy:
memcpy(tmp_skb->data, skb->data, skb->len);About the 64 byte alignement, it might be a bit more complex :)
With Eric's suggestion, you might find most packets are going to be aligned but the code should not depend on it always being true. Packets that get forwarded have header determined by the receiving interface.
Something like:
skb = skb_realloc_headroom(skb, 2);
if (!skb)
goto drop;
__skb_push(skb, 2);
memmove(skb->data, skb->data + 2, ETH_HLEN);
skb->data[ETH_HLEN] = 0;
skb->data[ETH_HLEN+1] = 0;
if (!IS_ALIGNED(skb->data, 16)) {
nskb = netdev_alloc_skb(dev, skb->len + 16);
if (!nskb)
goto drop2;
skb_reserve(nskb, PTR_ALIGN(skb->data, 16) - skb->data);
skb_put(skb, skb->len);
memcpy(nskb->data, skb->data, skb->len);
dev_kfree_skb(skb);
skb = nskb;
}Hi Eric and Stephen
Thank you for your suggestion.
I tried modification of "dev->hard_header_len".
However, there was no changed to a format of SKB received by kernel.
[Header:14octet] + [payload]
So, I can not a single memcpy.
Quoted 10 lines
Something like:
skb = skb_realloc_headroom(skb, 2); if (!skb) goto drop; __skb_push(skb, 2); memmove(skb->data, skb->data + 2, ETH_HLEN);skb->data[ETH_HLEN] = 0;
skb->data[ETH_HLEN+1] = 0;
Quoted 10 lines
if (!IS_ALIGNED(skb->data, 16)) {
nskb = netdev_alloc_skb(dev, skb->len + 16);
if (!nskb)
goto drop2;
skb_reserve(nskb, PTR_ALIGN(skb->data, 16) - skb->data);
skb_put(skb, skb->len);
memcpy(nskb->data, skb->data, skb->len);
dev_kfree_skb(skb);
skb = nskb;
}I am going to try modification using "memmove()" and "IS_ALIGNED()".
Thanks, Ohtake(OKISemi)
----- Original Message -----
From: "Stephen Hemminger" <[email protected]>
To: "Eric Dumazet" <[email protected]>
Cc: "Masayuki Ohtake" <[email protected]>; "Sam Ravnborg" <[email protected]>; "Joe Perches" <[email protected]>; "LKML" <[email protected]>; "ML netdev" <[email protected]>; "Greg Rose" <[email protected]>; "Maxime Bizon" <[email protected]>; "Kristoffer Glembo" <[email protected]>; "Ralf Baechle" <[email protected]>; "John Linn" <[email protected]>; "Randy Dunlap" <[email protected]>; "David S. Miller" <[email protected]>; "MeeGo" <[email protected]>; "Wang, Qi" <[email protected]>; "Wang, Yong Y" <[email protected]>; "Andrew" <[email protected]>; "Intel OTC" <[email protected]>; "Foster, Margie" <[email protected]>; "Toshiharu Okada" <[email protected]>; "Tomoya Morinaga" <[email protected]>; "Takahiro Shimizu" <[email protected]>
Sent: Friday, September 03, 2010 12:10 AM
Subject: Re: [PATCH] Gigabit Ethernet driver of Topcliff PCH
Quoted 37 lines · On Thu, 02 Sep 2010 15:40:47 +0200 Eric Dumazet <[email protected]> wrote:
Quoted 26 lines · Masayuki Ohtake
Hi Eric
Thank you for your comments.
Quoted 13 lines
I find hard to believe this driver needs to copy all outgoing frames on pre-allocated skbs.
drivers/net/pch_gbe/pch_gbe_main.c new file +9
-0+/* [Header:14][payload] ---> [Header:14][paddong:2][payload] */ +memcpy (tmp_skb->data, skb->data,ETH_HLEN ); + tmp_skb->data[ETH_HLEN ] =0x00 ; + tmp_skb->data[ETH_HLEN +1 ] =0x00 ; + tmp_skb->len = skb->len; +memcpy (&tmp_skb->data[ETH_HLEN +2 ], &skb->data[ETH_HLEN ], + (skb->len -ETH_HLEN )); + buffer_info->kernel_skb = skb; + skb = tmp_skb;Quoted 1 line
Whats the deal here please ?
This processing depends on hardware specification.
At the time of transmission.
Hardware accepts a packet in the following format.
[Header: 14octet] + [padding: 2octet] + [payload]
Also, it is necessary to align the head of a [Header: 14octet] at 64byte.Quoted 5 lines
In my knowledge, SKB received by kernel are the following format.
[padding: 2octet] + [Header:14octet] + [payload] Also, The head of [payload] has aligned at 16 byte.So, it has adjusted with the format of hardware by a copy.
The two bytes padding can be handled by network stack, if you force in your setup phase :
dev->hard_header_len=ETH_HLEN+ 2;
Quoted 5 lines
then, you can do a single memcpy:
memcpy(tmp_skb->data, skb->data, skb->len);About the 64 byte alignement, it might be a bit more complex :)
With Eric's suggestion, you might find most packets are going to be aligned but the code should not depend on it always being true. Packets that get forwarded have header determined by the receiving interface.
Something like:
skb = skb_realloc_headroom(skb, 2);
if (!skb)
goto drop;
__skb_push(skb, 2);
memmove(skb->data, skb->data + 2, ETH_HLEN);skb->data[ETH_HLEN] = 0;
skb->data[ETH_HLEN+1] = 0;
if (!IS_ALIGNED(skb->data, 16)) {
nskb = netdev_alloc_skb(dev, skb->len + 16);
if (!nskb)
goto drop2;
skb_reserve(nskb, PTR_ALIGN(skb->data, 16) - skb->data);
skb_put(skb, skb->len);
memcpy(nskb->data, skb->data, skb->len);
dev_kfree_skb(skb);
skb = nskb;
}Quoted 9 lines · Masayuki Ohtake
Hi Eric and Stephen
Thank you for your suggestion.
I tried modification of "
dev->hard_header_len".
However, there was no changed to a format of SKB received by kernel.
[Header:14octet] + [payload]So, I can not a single memcpy.
Hmm, maybe you did this at the wrong place ?
Take a look at other drivers how they do this
(network stack default hard_header_len to 14, in net/ethernet/eth.c, function ether_setup())
find drivers/net | xargs grep -n hard_header_len
Example in drivers/net/wan/hdlc.c
static void hdlc_setup_dev(struct net_device *dev)
{
/* Re-init all variables changed by HDLC protocol drivers,
* including ether_setup() called from hdlc_raw_eth.c.
*/
dev->flags = IFF_POINTOPOINT | IFF_NOARP;
dev->priv_flags = IFF_WAN_HDLC;
dev->mtu = HDLC_MAX_MTU;
dev->type = ARPHRD_RAWHDLC;
dev->hard_header_len = 16;
dev->addr_len = 0;
dev->header_ops = &hdlc_null_ops;
}Hi Eric
Thank you for your information.
I will confirm other drivers.
Thanks, Ohtake(OKISemi)
----- Original Message -----
From: "Eric Dumazet" <[email protected]>
To: "Masayuki Ohtake" <[email protected]>
Cc: "Stephen Hemminger" <[email protected]>; "Sam Ravnborg" <[email protected]>; "Joe Perches" <[email protected]>; "LKML" <[email protected]>; "ML netdev" <[email protected]>; "Greg Rose" <[email protected]>; "Maxime Bizon" <[email protected]>; "Kristoffer Glembo" <[email protected]>; "Ralf Baechle" <[email protected]>; "John Linn" <[email protected]>; "Randy Dunlap" <[email protected]>; "David S. Miller" <[email protected]>; "MeeGo" <[email protected]>; "Wang, Qi" <[email protected]>; "Wang, Yong Y" <[email protected]>; "Andrew" <[email protected]>; "Intel OTC" <[email protected]>; "Foster, Margie" <[email protected]>; "Toshiharu Okada" <[email protected]>; "Tomoya Morinaga" <[email protected]>; "Takahiro Shimizu" <[email protected]>
Sent: Friday, September 03, 2010 10:43 PM
Subject: Re: [PATCH] Gigabit Ethernet driver of Topcliff PCH
Quoted 39 lines
Le vendredi 03 septembre 2010 a 22:32 +0900, Masayuki Ohtake a ecrit :
Quoted 9 lines
Hi Eric and Stephen
Thank you for your suggestion.
I tried modification of "
dev->hard_header_len".
However, there was no changed to a format of SKB received by kernel.
[Header:14octet] + [payload]So, I can not a single memcpy.
Hmm, maybe you did this at the wrong place ?
Take a look at other drivers how they do this
(network stack default
hard_header_lento 14, innet/ethernet/eth.c, functionether_setup())find
drivers/net| xargs grep -nhard_header_lenExample in
drivers/net/wan/hdlc.cstatic void
hdlc_setup_dev(struct net_device *dev){ /* Re-init all variables changed by HDLC protocol drivers, * including ether_setup() called from hdlc_raw_eth.c. */ dev->flags = IFF_POINTOPOINT | IFF_NOARP; dev->priv_flags = IFF_WAN_HDLC; dev->mtu = HDLC_MAX_MTU; dev->type = ARPHRD_RAWHDLC; dev->hard_header_len = 16; dev->addr_len = 0; dev->header_ops = &hdlc_null_ops; }
Quoted 45 lines · Masayuki Ohtake
Hi Sam, Joe and Stephen
Thank you for your comments.
We have modified this driver for your comment.---
Gigabit Ethernet driver of Topcliff PCH
Patch created against 2.6.35Topcliff PCH is the platform controller hub that is going to be used in Intel's upcoming general embedded platform. All IO peripherals in Topcliff PCH are actually devices sitting on AMBA bus. Topcliff PCH has Gigabit Ethernet I/F. Using this I/F, it is able to access system devices connected to Gigabit Ethernet.
Signed-off-by Masayuki Ohtake <[email protected]>--- drivers/net/Kconfig | 10 + drivers/net/Makefile | 1 + drivers/net/pch_gbe/Makefile | 4 + drivers/net/pch_gbe/pch_gbe.h | 683 +++++++++ drivers/net/pch_gbe/pch_gbe_api.c | 246 ++++ drivers/net/pch_gbe/pch_gbe_api.h | 34 + drivers/net/pch_gbe/pch_gbe_ethtool.c | 618 ++++++++ drivers/net/pch_gbe/pch_gbe_main.c | 2591 +++++++++++++++++++++++++++++++++ drivers/net/pch_gbe/pch_gbe_param.c | 519 +++++++ drivers/net/pch_gbe/pch_gbe_phy.c | 276 ++++ drivers/net/pch_gbe/pch_gbe_phy.h | 35 + 11 files changed, 5017 insertions(+), 0 deletions(-) create mode 100644 drivers/net/pch_gbe/Makefile create mode 100644 drivers/net/pch_gbe/pch_gbe.h create mode 100644 drivers/net/pch_gbe/pch_gbe_api.c create mode 100644 drivers/net/pch_gbe/pch_gbe_api.h create mode 100644 drivers/net/pch_gbe/pch_gbe_ethtool.c create mode 100644 drivers/net/pch_gbe/pch_gbe_main.c create mode 100644 drivers/net/pch_gbe/pch_gbe_param.c create mode 100644 drivers/net/pch_gbe/pch_gbe_phy.c create mode 100644 drivers/net/pch_gbe/pch_gbe_phy.hdrivers/net/Kconfig +0
-0
drivers/net/Kconfig menuconfig NETDEV_1000 · line 2009
Quoted 6 lines
drivers/net/Kconfig +3
-0@@ -2004,6 +2004,16 @@ menuconfig NETDEV_1000 If you say N, all options in this submenu will be skipped and disabled. if NETDEV_1000 +config PCH_GBE + tristate "PCH Gigabit Ethernet" + depends on PCI
IMO it's not nice to list this driver before others that are already there.
drivers/net/Kconfig menuconfig NETDEV_1000 · line 2011
Quoted 2 lines
drivers/net/Kconfig +2
-0+ ---help--- + This is an gigabit ethernet driver for Topcliff PCH.
This is a gigabit
You aren't going to modify this text after the product is released, are you? Might as well make it better now:
drivers/net/Kconfig menuconfig NETDEV_1000 · line 2012
Quoted 1 line
drivers/net/Kconfig +1
-0+ Topcliff PCH is the platform controller hub that is going to be used
Topcliff PCH is the platform controller hub that is used in Intel's general embedded platform.
drivers/net/Kconfig menuconfig NETDEV_1000 · line 2014
Quoted 2 lines
drivers/net/Kconfig +2
-0+ in Intel's upcoming general embedded platform. + Topcliff PCH has Gigabit Ethernet I/F. Using this I/F, it is able to
Change "I/F" to "interface".
Quoted 5 lines
drivers/net/Kconfig +2
-0+ access system devices connected to Gigabit Ethernet. + This driver enables Gigabit Ethernet function. config ACENIC tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support"
Signature · 2 lines
~Randy *** Remember to use Documentation/SubmitChecklist when testing your code ***
Quoted 1 line · Masayuki Ohtake
We have modified this driver for your comment.
Some trivial logging message cleanups:
Missing newline
Alignment
Grammar
80 column coalescing
--- drivers/net/pch_gbe/pch_gbe_main.c | 180 ++++++++++++++++------------------- drivers/net/pch_gbe/pch_gbe_param.c | 36 +++----- drivers/net/pch_gbe/pch_gbe_phy.c | 2 +- 3 files changed, 94 insertions(+), 124 deletions(-)
drivers/net/pch_gbe/pch_gbe_main.c +81 -99
@@ -284,7 +284,7 @@ s32 pch_gbe_mac_force_mac_fc(struct pch_gbe_hw *hw) rx_fctrl &= ~PCH_GBE_FL_CTRL_EN ;iowrite32 (rx_fctrl, &hw->reg->RX_FCTRL);pr_debug ("RX_FCTRL reg : 0x%08x mac->tx_fc_enable : %d\n" , -ioread32 (&hw->reg->RX_FCTRL), mac->tx_fc_enable); +ioread32 (&hw->reg->RX_FCTRL), mac->tx_fc_enable);return 0 ; }
@@ -299,7 +299,7 @@ void pch_gbe_mac_set_wol_event(struct pch_gbe_hw *hw, u32 wu_evt)FUNC_ENTER ();pr_debug ("wu_evt : 0x%08x ADDR_MASK reg : 0x%08x\n" , - wu_evt,ioread32 (&hw->reg->ADDR_MASK)); + wu_evt,ioread32 (&hw->reg->ADDR_MASK));if (wu_evt) {/* Set Wake-On-Lan address mask */
@@ -360,8 +360,8 @@ u16 pch_gbe_mac_ctrl_miim(struct pch_gbe_hw *hw, u32 addr, u32 dir, u32 reg,spin_unlock_irqrestore (&hw->miim_lock, flags);pr_debug ("PHY %s: reg=%d, data=0x%04X\n" , - dir ==PCH_GBE_MIIM_OPER_READ ?"READ" :"WRITE" , reg, - dir ==PCH_GBE_MIIM_OPER_READ ? data_out : data); + dir ==PCH_GBE_MIIM_OPER_READ ?"READ" :"WRITE" , reg, + dir ==PCH_GBE_MIIM_OPER_READ ? data_out : data);return (u16 ) data_out; }
@@ -394,9 +394,9 @@ void pch_gbe_mac_set_pause_packet(struct pch_gbe_hw *hw)iowrite32 (PCH_GBE_PS_PKT_RQ , &hw->reg->PAUSE_REQ);pr_debug ("PAUSE_PKT1-5 reg : 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n" , -ioread32 (&hw->reg->PAUSE_PKT1),ioread32 (&hw->reg->PAUSE_PKT2), -ioread32 (&hw->reg->PAUSE_PKT3),ioread32 (&hw->reg->PAUSE_PKT4), -ioread32 (&hw->reg->PAUSE_PKT5)); +ioread32 (&hw->reg->PAUSE_PKT1),ioread32 (&hw->reg->PAUSE_PKT2), +ioread32 (&hw->reg->PAUSE_PKT3),ioread32 (&hw->reg->PAUSE_PKT4), +ioread32 (&hw->reg->PAUSE_PKT5));return ; }
@@ -607,7 +607,7 @@ static void pch_gbe_free_irq(struct pch_gbe_adapter *adapter)free_irq (adapter->pdev->irq, netdev);if (adapter->have_msi) {pci_disable_msi (adapter->pdev); -pr_debug ("call pci_disable_msi" ); +pr_debug ("call pci_disable_msi\n" ); } }
@@ -677,8 +677,9 @@ static void pch_gbe_configure_tx(struct pch_gbe_adapter *adapter)u32 tdba, tdlen, dctrl;FUNC_ENTER (); -pr_debug ("dma adr = 0x%08x size = 0x%08x\n" , - adapter->tx_ring->dma, adapter->tx_ring->size); +pr_debug ("dma addr = 0x%08llx size = 0x%08x\n" , + (unsigned long long )adapter->tx_ring->dma, + adapter->tx_ring->size);/* Setup the HW Tx Head and Tail descriptor pointers */ tdba = adapter->tx_ring->dma;
@@ -731,8 +732,9 @@ static void pch_gbe_configure_rx(struct pch_gbe_adapter *adapter)u32 rdba, rdlen, rctl, rxdma;FUNC_ENTER (); -pr_debug ("dma adr = 0x%08x size = 0x%08x\n" , - adapter->rx_ring->dma, adapter->rx_ring->size); +pr_debug ("dma adr = 0x%08llx size = 0x%08x\n" , + (unsigned long long )adapter->rx_ring->dma, + adapter->rx_ring->size);pch_gbe_mac_force_mac_fc (hw);
@@ -746,8 +748,8 @@ static void pch_gbe_configure_rx(struct pch_gbe_adapter *adapter)iowrite32 (rxdma, &hw->reg->DMA_CTRL);pr_debug ("MAC_RX_EN reg = 0x%08x DMA_CTRL reg = 0x%08x\n" , -ioread32 (&hw->reg->MAC_RX_EN), -ioread32 (&hw->reg->DMA_CTRL)); +ioread32 (&hw->reg->MAC_RX_EN), +ioread32 (&hw->reg->DMA_CTRL));/* Setup the HW Rx Head and Tail Descriptor Pointers and * the Base and Length of the Rx Descriptor Ring */
@@ -827,8 +829,7 @@ static void pch_gbe_clean_tx_ring(struct pch_gbe_adapter *adapter, buffer_info = &tx_ring->buffer_info[i];pch_gbe_unmap_and_free_tx_resource (adapter, buffer_info); } -pr_debug ("call pch_gbe_unmap_and_free_tx_resource() %d count\n" , - i); +pr_debug ("call pch_gbe_unmap_and_free_tx_resource() %d count\n" , i); size = (unsigned long )sizeof (struct pch_gbe_buffer ) * tx_ring->count;memset (tx_ring->buffer_info,0 , size);
@@ -861,8 +862,7 @@ pch_gbe_clean_rx_ring(struct pch_gbe_adapter *adapter, buffer_info = &rx_ring->buffer_info[i];pch_gbe_unmap_and_free_rx_resource (adapter, buffer_info); } -pr_debug ("call pch_gbe_unmap_and_free_rx_resource() %d count\n" , - i); +pr_debug ("call pch_gbe_unmap_and_free_rx_resource() %d count\n" , i); size = (unsigned long )sizeof (struct pch_gbe_buffer ) * rx_ring->count;memset (rx_ring->buffer_info,0 , size);
@@ -964,14 +964,16 @@ static void pch_gbe_watchdog(unsigned long data) hw->mac.link_duplex);/* Set the communication mode */ pch_gbe_set_mode (adapter, hw->mac.link_speed, - hw->mac.link_duplex); -pr_debug ("NIC Link is Up %d Mbps %s-Duplex\n" , - cmd.speed, cmd.duplex ==DUPLEX_FULL ?"Full" :"Half" ); + hw->mac.link_duplex); +netdev_dbg (netdev, +"Link is Up %d Mbps %s-Duplex\n" , + cmd.speed, + cmd.duplex ==DUPLEX_FULL ?"Full" :"Half" );netif_carrier_on (netdev);netif_wake_queue (netdev); }else if ((!mii_link_ok (&adapter->mii)) && - (netif_carrier_ok (netdev))) { -pr_debug ("NIC Link is Down\n" ); + (netif_carrier_ok (netdev))) { +netdev_dbg (netdev,"NIC Link is Down\n" ); hw->mac.link_speed =SPEED_10 ; hw->mac.link_duplex =DUPLEX_HALF ;netif_carrier_off (netdev);
@@ -1183,7 +1185,7 @@ static irqreturn_t pch_gbe_intr(int irq, void *data) } }pr_debug ("return = 0x%08x INT_EN reg = 0x%08x\n" , -IRQ_HANDLED ,ioread32 (&hw->reg->INT_EN)); +IRQ_HANDLED ,ioread32 (&hw->reg->INT_EN));return IRQ_HANDLED ; }
@@ -1238,9 +1240,9 @@ pch_gbe_alloc_rx_buffers(struct pch_gbe_adapter *adapter, rx_desc->buffer_addr = (buffer_info->dma); rx_desc->gbec_status =DSC_INIT16 ; -pr_debug ("i = %d buffer_info->dma = 0x%x " -"buffer_info->length = 0x%x\n" , - i, buffer_info->dma, buffer_info->length); +pr_debug ("i = %d buffer_info->dma = 0x08%llx buffer_info->length = 0x%x\n" , + i, (unsigned long long )buffer_info->dma, + buffer_info->length);if (unlikely (++i == rx_ring->count)) i =0 ;
@@ -1311,7 +1313,7 @@ pch_gbe_clean_tx(struct pch_gbe_adapter *adapter, i = tx_ring->next_to_clean; tx_desc =PCH_GBE_TX_DESC (*tx_ring, i);pr_debug ("gbec_status:0x%04x dma_status:0x%04x\n" , - tx_desc->gbec_status, tx_desc->dma_status); + tx_desc->gbec_status, tx_desc->dma_status);while ((tx_desc->gbec_status &DSC_INIT16 ) ==0x0000 ) {pr_debug ("gbec_status:0x%04x\n" , tx_desc->gbec_status);
@@ -1321,7 +1323,7 @@ pch_gbe_clean_tx(struct pch_gbe_adapter *adapter,if ((tx_desc->gbec_status &PCH_GBE_TXD_GMAC_STAT_ABT )) { adapter->stats.tx_aborted_errors++; -pr_err ("Transfer Aboat Error\n" ); +pr_err ("Transfer Abort Error\n" ); }else if ((tx_desc->gbec_status &PCH_GBE_TXD_GMAC_STAT_CRSER ) ) { adapter->stats.tx_carrier_errors++;
@@ -1353,9 +1355,8 @@ pch_gbe_clean_tx(struct pch_gbe_adapter *adapter,skb_trim (buffer_info->skb,0 ); }if (buffer_info->kernel_skb) { -pr_debug - ("free buffer_info->kernel_skb adr: 0x%x\n" , - (u32)(buffer_info->kernel_skb)); +pr_debug ("free buffer_info->kernel_skb adr: 0x%x\n" , + (u32)(buffer_info->kernel_skb));dev_kfree_skb (buffer_info->kernel_skb); buffer_info->kernel_skb =NULL ; }
@@ -1368,8 +1369,8 @@ pch_gbe_clean_tx(struct pch_gbe_adapter *adapter,if (cleaned_count++ ==PCH_GBE_TX_WEIGHT )break ; } -pr_debug ("called pch_gbe_unmap_and_free_tx_resource() %dcount\n" , - cleaned_count); +pr_debug ("called pch_gbe_unmap_and_free_tx_resource() %d count\n" , + cleaned_count);/* Recover from running out of Tx resources in xmit_frame */ if (unlikely (cleaned && (netif_queue_stopped (adapter->netdev)))) {netif_wake_queue (adapter->netdev);
@@ -1439,8 +1440,7 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,/* Prefetch the packet */ prefetch (skb->data); -pr_debug - ("RxDecNo = 0x%04x Status[DMA:0x%02x GBE:0x%04x " +pr_debug ("RxDecNo = 0x%04x Status[DMA:0x%02x GBE:0x%04x " "TCP:0x%08x] BufInf = 0x%08x\n" , i, dma_status, gbec_status, tcp_ip_status, (u32) (buffer_info));
@@ -1528,9 +1528,8 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter, } (*work_done)++; netdev->last_rx = jiffies; -pr_debug - ("Receive skb->ip_summed: %d length: %d\n" , - skb->ip_summed, length); +pr_debug ("Receive skb->ip_summed: %d length: %d\n" , + skb->ip_summed, length); } dorrop:/* return some buffers to hardware, one at a time is too slow */
@@ -1568,8 +1567,7 @@ int pch_gbe_setup_tx_resources(struct pch_gbe_adapter *adapter, size = (int )sizeof (struct pch_gbe_buffer ) * tx_ring->count; tx_ring->buffer_info =vmalloc (size);if (!tx_ring->buffer_info) { -pr_err ("Unable to allocate memory " -"for the buffer infomation\n" ); +pr_err ("Unable to allocate memory for the buffer infomation\n" );return -ENOMEM ; }memset (tx_ring->buffer_info,0 , size);
@@ -1580,8 +1578,7 @@ int pch_gbe_setup_tx_resources(struct pch_gbe_adapter *adapter,pci_alloc_consistent (pdev, tx_ring->size, &tx_ring->dma);if (!tx_ring->desc) {vfree (tx_ring->buffer_info); -pr_err ("Unable to allocate memory " -"for the transmit descriptor ring\n" ); +pr_err ("Unable to allocate memory for the transmit descriptor ring\n" );return -ENOMEM ; }memset (tx_ring->desc,0 , tx_ring->size);
@@ -1594,10 +1591,10 @@ int pch_gbe_setup_tx_resources(struct pch_gbe_adapter *adapter, tx_desc =PCH_GBE_TX_DESC (*tx_ring, desNo); tx_desc->gbec_status =DSC_INIT16 ; } -pr_debug ("tx_ring->desc = 0x%08x tx_ring->dma = 0x%08x\n" -"next_to_clean = 0x%08x next_to_use = 0x%08x\n" , - (u32 ) tx_ring->desc, tx_ring->dma, - tx_ring->next_to_clean, tx_ring->next_to_use); +pr_debug ("tx_ring->desc = 0x%08x tx_ring->dma = 0x%08llx\n" +"next_to_clean = 0x%08x next_to_use = 0x%08x\n" , + (u32 ) tx_ring->desc, (unsigned long long )tx_ring->dma, + tx_ring->next_to_clean, tx_ring->next_to_use);return 0 ; }
@@ -1621,8 +1618,7 @@ int pch_gbe_setup_rx_resources(struct pch_gbe_adapter *adapter, size = (int )sizeof (struct pch_gbe_buffer ) * rx_ring->count; rx_ring->buffer_info =vmalloc (size);if (!rx_ring->buffer_info) { -pr_err ("Unable to allocate memory " -"for the receive descriptor ring\n" ); +pr_err ("Unable to allocate memory for the receive descriptor ring\n" );return -ENOMEM ; }memset (rx_ring->buffer_info,0 , size);
@@ -1631,8 +1627,7 @@ int pch_gbe_setup_rx_resources(struct pch_gbe_adapter *adapter,pci_alloc_consistent (pdev, rx_ring->size, &rx_ring->dma);if (!rx_ring->desc) { -pr_err ("Unable to allocate memory " -"for the receive descriptor ring\n" ); +pr_err ("Unable to allocate memory for the receive descriptor ring\n" );vfree (rx_ring->buffer_info);return -ENOMEM ; }
@@ -1643,10 +1638,10 @@ int pch_gbe_setup_rx_resources(struct pch_gbe_adapter *adapter, rx_desc =PCH_GBE_RX_DESC (*rx_ring, desNo); rx_desc->gbec_status =DSC_INIT16 ; } -pr_debug ("rx_ring->desc = 0x%08x rx_ring->dma = 0x%08x " -"next_to_clean = 0x%08x next_to_use = 0x%08x\n" , - (u32 ) rx_ring->desc, rx_ring->dma, - rx_ring->next_to_clean, rx_ring->next_to_use); +pr_debug ("rx_ring->desc = 0x%08x rx_ring->dma = 0x%08llx " +"next_to_clean = 0x%08x next_to_use = 0x%08x\n" , + (u32 ) rx_ring->desc, (unsigned long long )rx_ring->dma, + rx_ring->next_to_clean, rx_ring->next_to_use);return 0 ; }
@@ -1714,8 +1709,8 @@ static int pch_gbe_request_irq(struct pch_gbe_adapter *adapter) flags, netdev->name, netdev);if (err)pr_err ("Unable to allocate interrupt Error: %d\n" , err); -pr_debug ("adapter->have_msi : %d flags : 0x%04x " -"return : 0x%04x\n" , adapter->have_msi, flags, err); +pr_debug ("adapter->have_msi : %d flags : 0x%04x return : 0x%04x\n" , + adapter->have_msi, flags, err);return err; }
@@ -1834,14 +1829,13 @@ static int pch_gbe_sw_init(struct pch_gbe_adapter *adapter)pch_gbe_init_stats (adapter);pr_debug ("vendor_id : 0x%08x device_id : 0x%08x\n" , - hw->vendor_id, hw->device_id); -pr_debug ("subsystem vendor_id :0x%08x device_id :0x%08x\n" -"revision_id :0x%08x\n" , hw->subsystem_vendor_id, - hw->subsystem_device_id, hw->revision_id); -pr_debug ("rx_buffer_len : %d mac.max_frame_size : %d " -"mac.min_frame_size : %d\n" , - (u32 ) adapter->rx_buffer_len, - hw->mac.max_frame_size, hw->mac.min_frame_size); + hw->vendor_id, hw->device_id); +pr_debug ("subsystem vendor_id :0x%08x device_id :0x%08x revision_id :0x%08x\n" , + hw->subsystem_vendor_id, + hw->subsystem_device_id, hw->revision_id); +pr_debug ("rx_buffer_len : %d mac.min_frame_size : %d mac.max_frame_size : %d\n" , + (u32 ) adapter->rx_buffer_len, + hw->mac.min_frame_size, hw->mac.max_frame_size);return 0 ; }
@@ -1927,8 +1921,8 @@ static int pch_gbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)return NETDEV_TX_OK ; }if (unlikely (skb->len > (adapter->hw.mac.max_frame_size -4 ))) { -pr_err ("Transfer length Error: %d over %d\n" , - skb->len, adapter->hw.mac.max_frame_size); +pr_err ("Transfer length Error: skb len: %d > max: %d\n" , + skb->len, adapter->hw.mac.max_frame_size);dev_kfree_skb_any (skb); adapter->stats.tx_length_errors++;return NETDEV_TX_BUSY ;
@@ -1940,10 +1934,8 @@ static int pch_gbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)if (unlikely (!PCH_GBE_DESC_UNUSED (tx_ring))) {netif_stop_queue (netdev);spin_unlock_irqrestore (&tx_ring->tx_lock, flags); -pr_debug - ("Return : BUSY next_to use : 0x%08x " -"next_to clean : 0x%08x\n" , - tx_ring->next_to_use, tx_ring->next_to_clean); +pr_debug ("Return : BUSY next_to use : 0x%08x next_to clean : 0x%08x\n" , + tx_ring->next_to_use, tx_ring->next_to_clean);return NETDEV_TX_BUSY ; }spin_unlock_irqrestore (&tx_ring->tx_lock, flags);
@@ -2023,9 +2015,8 @@ static void pch_gbe_set_multi(struct net_device *netdev) PCH_GBE_MAR_ENTRIES);kfree (mta_list); -pr_debug ("RX_MODE reg(check bit31,30 ADD,MLT) : 0x%08x " -"netdev->mc_count : 0x%08x\n" , -ioread32 (&hw->reg->RX_MODE), mc_count); +pr_debug ("RX_MODE reg(check bit31,30 ADD,MLT) : 0x%08x netdev->mc_count : 0x%08x\n" , +ioread32 (&hw->reg->RX_MODE), mc_count); }/**
@@ -2052,17 +2043,11 @@ static int pch_gbe_set_mac(struct net_device *netdev, void *addr) ret_val =0 ; }pr_debug ("ret_val : 0x%08x\n" , ret_val); -pr_debug ("dev_addr : %02x:%02x:%02x:%02x:%02x:%02x\n" , - netdev->dev_addr[0 ], netdev->dev_addr[1 ], - netdev->dev_addr[2 ], netdev->dev_addr[3 ], - netdev->dev_addr[4 ], netdev->dev_addr[5 ]); -pr_debug ("mac_addr : %02x:%02x:%02x:%02x:%02x:%02x\n" , - adapter->hw.mac.addr[0 ], adapter->hw.mac.addr[1 ], - adapter->hw.mac.addr[2 ], adapter->hw.mac.addr[3 ], - adapter->hw.mac.addr[4 ], adapter->hw.mac.addr[5 ]); +pr_debug ("dev_addr : %pM\n" , netdev->dev_addr); +pr_debug ("mac_addr : %pM\n" , adapter->hw.mac.addr);pr_debug ("MAC_ADR1AB reg : 0x%08x 0x%08x\n" , -ioread32 (&adapter->hw.reg->mac_adr[0 ].high), -ioread32 (&adapter->hw.reg->mac_adr[0 ].low)); +ioread32 (&adapter->hw.reg->mac_adr[0 ].high), +ioread32 (&adapter->hw.reg->mac_adr[0 ].low));return ret_val; }
@@ -2102,10 +2087,9 @@ static int pch_gbe_change_mtu(struct net_device *netdev, int new_mtu)else pch_gbe_reset (adapter); -pr_debug - ("max_frame : %d rx_buffer_len : %d mtu : %d max_frame_size : %d\n" , - max_frame, (u32 ) adapter->rx_buffer_len, netdev->mtu, - adapter->hw.mac.max_frame_size); +pr_debug ("max_frame : %d rx_buffer_len : %d mtu : %d max_frame_size : %d\n" , + max_frame, (u32 ) adapter->rx_buffer_len, netdev->mtu, + adapter->hw.mac.max_frame_size);return 0 ; }
@@ -2184,7 +2168,7 @@ static int pch_gbe_napi_poll(struct napi_struct *napi, int budget) }pr_debug ("poll_end_flag : %d work_done : %d budget : %d\n" , - poll_end_flag, work_done, budget); + poll_end_flag, work_done, budget);return work_done; }
@@ -2242,7 +2226,7 @@ static pci_ers_result_t pch_gbe_io_slot_reset(struct pci_dev *pdev)FUNC_ENTER ();if (pci_enable_device (pdev)) { -pr_err ("Cannot re-enable PCI device after reset.\n" ); +pr_err ("Cannot re-enable PCI device after reset\n" );return PCI_ERS_RESULT_DISCONNECT ; }pci_set_master (pdev);
@@ -2263,8 +2247,7 @@ static void pch_gbe_io_resume(struct pci_dev *pdev)FUNC_ENTER ();if (netif_running (netdev)) {if (pch_gbe_up (adapter)) { -pr_debug ("can't bring device back up after reset\n" - ); +pr_debug ("can't bring device back up after reset\n" );return ; } }
@@ -2398,8 +2381,7 @@ static int pch_gbe_probe(struct pci_dev *pdev, ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 ));if (ret) { -pr_err ("ERR: " -"No usable DMA configuration, aborting\n" ); +pr_err ("ERR: No usable DMA configuration, aborting\n" ); goto err_disable_device; } }
@@ -2414,7 +2396,7 @@ static int pch_gbe_probe(struct pci_dev *pdev, netdev =alloc_etherdev ((int )sizeof (struct pch_gbe_adapter ));if (!netdev) { ret = -ENOMEM ; -pr_err ("ERR: Can't allocates and sets up an Ethernet device\n" ); +pr_err ("ERR: Can't allocate and set up an Ethernet device\n" ); goto err_release_pci; }SET_NETDEV_DEV (netdev, &pdev->dev);
@@ -2558,10 +2540,10 @@ static int __init pch_gbe_init_module(void) ret =pci_register_driver (&pch_gbe_pcidev);if (copybreak !=PCH_GBE_COPYBREAK_DEFAULT ) {if (copybreak ==0 ) { -pr_info ("pch_gbe: copybreak disabled\n" ); +pr_info ("copybreak disabled\n" ); }else { -pr_info ("pch_gbe: copybreak enabled for " -"packets <= %u bytes\n" , copybreak); +pr_info ("copybreak enabled for packets <= %u bytes\n" , + copybreak); } }return ret;
@@ -2569,7 +2551,7 @@ static int __init pch_gbe_init_module(void) static void __exit pch_gbe_exit_module(void) { -pr_debug ("pch_gbe_exit_module\n" ); +FUNC_ENTER ();pci_unregister_driver (&pch_gbe_pcidev);pr_info ("%s - unregister\n" ,DRV_STRING );
drivers/net/pch_gbe/pch_gbe_param.c +12 -24
@@ -197,8 +197,7 @@ static int pch_gbe_validate_option(int *value, struct pch_gbe_option *opt,break ;case range_option:if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { -pr_debug ( -"%s set to %i\n" , opt->name, *value); +pr_debug ("%s set to %i\n" , opt->name, *value);return 0 ; }break ;
@@ -221,7 +220,7 @@ static int pch_gbe_validate_option(int *value, struct pch_gbe_option *opt, }pr_debug ("Invalid %s value specified (%i) %s\n" , - opt->name, *value, opt->err); + opt->name, *value, opt->err); *value = opt->def;return -1 ; }
@@ -315,9 +314,7 @@ static void pch_gbe_check_copper_options(struct pch_gbe_adapter *adapter) .p = an_list} } };if (speed || dplx) { -pr_debug ( -"AutoNeg specified along with Speed or Duplex, " -"parameter ignored\n" ); +pr_debug ("AutoNeg specified along with Speed or Duplex, AutoNeg parameter ignored\n" ); hw->phy.autoneg_advertised = opt.def; }else { hw->phy.autoneg_advertised = AutoNeg;
@@ -331,15 +328,13 @@ static void pch_gbe_check_copper_options(struct pch_gbe_adapter *adapter)case 0 : hw->mac.autoneg = hw->mac.fc_autoneg =1 ;if ((speed || dplx)) -pr_debug ( -"Speed and duplex autonegotiation enabled\n" ); +pr_debug ("Speed and duplex autonegotiation enabled\n" ); hw->mac.link_speed =SPEED_10 ; hw->mac.link_duplex =DUPLEX_HALF ;break ;case PHY_HALF_DUPLEX :pr_debug ("Half Duplex specified without Speed\n" ); -pr_debug ("Using Autonegotiation at " -"Half Duplex only\n" ); +pr_debug ("Using Autonegotiation at Half Duplex only\n" ); hw->mac.autoneg = hw->mac.fc_autoneg =1 ; hw->phy.autoneg_advertised =PHY_ADVERTISE_10_HALF |PHY_ADVERTISE_100_HALF ;
@@ -348,8 +343,7 @@ static void pch_gbe_check_copper_options(struct pch_gbe_adapter *adapter)break ;case PHY_FULL_DUPLEX :pr_debug ("Full Duplex specified without Speed\n" ); -pr_debug ("Using Autonegotiation at " -"Full Duplex only\n" ); +pr_debug ("Using Autonegotiation at Full Duplex only\n" ); hw->mac.autoneg = hw->mac.fc_autoneg =1 ; hw->phy.autoneg_advertised =PHY_ADVERTISE_10_FULL | PHY_ADVERTISE_100_FULL |
@@ -358,8 +352,7 @@ static void pch_gbe_check_copper_options(struct pch_gbe_adapter *adapter) hw->mac.link_duplex =DUPLEX_FULL ;break ;case PHY_SPEED_10 : -pr_debug ("10 Mbps Speed specified " -"without Duplex\n" ); +pr_debug ("10 Mbps Speed specified without Duplex\n" );pr_debug ("Using Autonegotiation at 10 Mbps only\n" ); hw->mac.autoneg = hw->mac.fc_autoneg =1 ; hw->phy.autoneg_advertised = PHY_ADVERTISE_10_HALF |
@@ -382,10 +375,8 @@ static void pch_gbe_check_copper_options(struct pch_gbe_adapter *adapter) hw->mac.link_duplex =DUPLEX_FULL ;break ;case PHY_SPEED_100 : -pr_debug ("100 Mbps Speed specified " -"without Duplex\n" ); -pr_debug ("Using Autonegotiation at " -"100 Mbps only\n" ); +pr_debug ("100 Mbps Speed specified without Duplex\n" ); +pr_debug ("Using Autonegotiation at 100 Mbps only\n" ); hw->mac.autoneg = hw->mac.fc_autoneg =1 ; hw->phy.autoneg_advertised =PHY_ADVERTISE_100_HALF |PHY_ADVERTISE_100_FULL ;
@@ -407,17 +398,14 @@ static void pch_gbe_check_copper_options(struct pch_gbe_adapter *adapter) hw->mac.link_duplex =DUPLEX_FULL ;break ;case PHY_SPEED_1000 : -pr_debug ("1000 Mbps Speed specified without " -"Duplex\n" ); +pr_debug ("1000 Mbps Speed specified without Duplex\n" ); goto full_duplex_only;case PHY_SPEED_1000 +PHY_HALF_DUPLEX : -pr_debug ( -"Half Duplex is not supported at 1000 Mbps\n" ); +pr_debug ("Half Duplex is not supported at 1000 Mbps\n" );/* fall through */ case PHY_SPEED_1000 +PHY_FULL_DUPLEX : full_duplex_only: -pr_debug ( -"Using Autonegotiation at 1000 Mbps Full Duplex only\n" ); +pr_debug ("Using Autonegotiation at 1000 Mbps Full Duplex only\n" ); hw->mac.autoneg = hw->mac.fc_autoneg =1 ; hw->phy.autoneg_advertised =PHY_ADVERTISE_1000_FULL ; hw->mac.link_speed =SPEED_1000 ;
drivers/net/pch_gbe/pch_gbe_phy.c +1 -1
@@ -118,7 +118,7 @@ s32 pch_gbe_phy_get_id(struct pch_gbe_hw *hw) phy->id = ((phy->id <<6 ) | ((phy_id2 &0xFC00 ) >>10 )); phy->revision = (u32) (phy_id2 &0x000F );pr_debug ("phy->id : 0x%08x phy->revision : 0x%08x\n" , - phy->id, phy->revision); + phy->id, phy->revision);return 0 ; }
PATCH 1/1 drivers/net/pch_gbe: Use bool not unsigned char
Perhaps this is clearer.
--- drivers/net/pch_gbe/pch_gbe.h | 6 +++--- drivers/net/pch_gbe/pch_gbe_main.c | 33 +++++++++++++++++---------------- 2 files changed, 20 insertions(+), 19 deletions(-)
drivers/net/pch_gbe/pch_gbe.h +3 -3
@@ -638,9 +638,9 @@ struct pch_gbe_adapter {struct pch_gbe_rx_ring *rx_ring;unsigned long rx_buffer_len;unsigned long tx_queue_len; -unsigned char rx_csum; -unsigned char tx_csum; -unsigned char have_msi; +bool rx_csum; +bool tx_csum; +bool have_msi; };/**
drivers/net/pch_gbe/pch_gbe_main.c +17 -16
@@ -711,7 +711,7 @@ static void pch_gbe_setup_rctl(struct pch_gbe_adapter *adapter) tcpip =ioread32 (&hw->reg->TCPIP_ACC); -if (adapter->rx_csum == true) { +if (adapter->rx_csum) { tcpip &= ~PCH_GBE_RX_TCPIPACC_OFF ; tcpip |=PCH_GBE_RX_TCPIPACC_EN ; }else {
@@ -1005,7 +1005,7 @@ static void pch_gbe_tx_queue(struct pch_gbe_adapter *adapter, frame_ctrl =0 ;if (unlikely (skb->len <PCH_GBE_SHORT_PKT )) frame_ctrl |=PCH_GBE_TXD_CTRL_APAD ; -if (unlikely (adapter->tx_csum == false)) +if (unlikely (!adapter->tx_csum)) frame_ctrl |=PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF ;/* Performs checksum processing */
@@ -1013,7 +1013,7 @@ static void pch_gbe_tx_queue(struct pch_gbe_adapter *adapter,* It is because the hardware accelerator does not support a checksum, * when the received data size is less than 64 bytes. */ -if ((skb->len <PCH_GBE_SHORT_PKT ) && (adapter->tx_csum == true)) { +if ((skb->len <PCH_GBE_SHORT_PKT ) && (adapter->tx_csum)) { frame_ctrl |=PCH_GBE_TXD_CTRL_APAD |PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF ;if (skb->protocol ==htons (ETH_P_IP )) {
@@ -1161,7 +1161,7 @@ static irqreturn_t pch_gbe_intr(int irq, void *data)pr_err ("Rx descriptor is empty\n" ); int_en =ioread32 (&hw->reg->INT_EN);iowrite32 ((int_en & ~PCH_GBE_INT_RX_DSC_EMP ), &hw->reg->INT_EN); -if (hw->mac.tx_fc_enable == true) { +if (hw->mac.tx_fc_enable) {/* Set Pause packet */ pch_gbe_mac_set_pause_packet (hw); }
@@ -1296,7 +1296,7 @@ static void pch_gbe_alloc_tx_buffers(struct pch_gbe_adapter *adapter,* true: Cleaned the descriptor * false: Not cleaned the descriptor */ -static unsigned char +static bool pch_gbe_clean_tx (struct pch_gbe_adapter *adapter,struct pch_gbe_tx_ring *tx_ring) {
@@ -1305,7 +1305,7 @@ pch_gbe_clean_tx(struct pch_gbe_adapter *adapter,struct sk_buff *skb;unsigned int i;unsigned int cleaned_count =0 ; -unsigned char cleaned = false; +bool cleaned = false;FUNC_ENTER ();pr_debug ("next_to_clean : %d\n" , tx_ring->next_to_clean);
@@ -1394,7 +1394,7 @@ pch_gbe_clean_tx(struct pch_gbe_adapter *adapter,* true: Cleaned the descriptor * false: Not cleaned the descriptor */ -static unsigned char +static bool pch_gbe_clean_rx (struct pch_gbe_adapter *adapter,struct pch_gbe_rx_ring *rx_ring,int *work_done,int work_to_do)
@@ -1407,7 +1407,7 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,unsigned char tmp_packet[ETH_HLEN ];unsigned int i;unsigned int cleaned_count =0 ; -unsigned char cleaned = false; +bool cleaned = false;struct sk_buff *skb;u8 dma_status;u16 gbec_status;
@@ -1462,7 +1462,7 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter, length = (rx_desc->rx_words_eob) -3 -2 ;/* Decide the data conversion method */ -if (adapter->rx_csum != true) { +if (!adapter->rx_csum) {/* [Header:14][payload] */ skb_padding_flag =0 ; skb_copy_flag =1 ;
@@ -2131,8 +2131,8 @@ static void pch_gbe_tx_timeout(struct net_device *netdev)* @napi: Pointer of polling device struct * @budget: The maximum number of a packet * Returns -* 0: Exit the polling mode -* 1: Continue the polling mode +* false: Exit the polling mode +* true: Continue the polling mode */ static int pch_gbe_napi_poll (struct napi_struct *napi,int budget) {
@@ -2140,15 +2140,15 @@ static int pch_gbe_napi_poll(struct napi_struct *napi, int budget) container_of(napi, struct pch_gbe_adapter, napi);struct net_device *netdev = adapter->netdev;int work_done =0 ; -int poll_end_flag =0 ; -int cleaned =0 ; +bool poll_end_flag = false; +bool cleaned = false;FUNC_ENTER ();pr_debug ("budget : %d\n" , budget);/* Keep link state information with original netdev */ if (!netif_carrier_ok (netdev)) { - poll_end_flag =1 ; + poll_end_flag = true; }else { cleaned =pch_gbe_clean_tx (adapter, adapter->tx_ring);pch_gbe_clean_rx (adapter, adapter->rx_ring, &work_done, budget);
@@ -2159,16 +2159,17 @@ static int pch_gbe_napi_poll(struct napi_struct *napi, int budget)* exit the polling mode */ if ((work_done < budget) || !netif_running (netdev)) - poll_end_flag =1 ; + poll_end_flag = true; } -if (poll_end_flag ==1 ) { +if (poll_end_flag) {napi_complete (napi);pch_gbe_irq_enable (adapter); }pr_debug ("poll_end_flag : %d work_done : %d budget : %d\n" , poll_end_flag, work_done, budget); +return work_done; }
Re: [PATCH] drivers/net/pch_gbe: Cleanup stats use
Use c90 initializers
Use memset
Use FIELD_SIZEOF
Remove stat_ from struct pch_gbe_stats members
Save offset from start of struct pch_gbe_hw_stats
All stat members are u64, so maybe the size field can be removed
--- drivers/net/pch_gbe/pch_gbe_ethtool.c | 32 +++++++++++++++++--------------- drivers/net/pch_gbe/pch_gbe_main.c | 28 +--------------------------- 2 files changed, 18 insertions(+), 42 deletions(-)
drivers/net/pch_gbe/pch_gbe_ethtool.c +17 -15
@@ -31,13 +31,18 @@* pch_gbe_stats - Stats item infomation */ struct pch_gbe_stats { -signed char stat_string[ETH_GSTRING_LEN ]; -int sizeof_stat; -int stat_offset; +signed char string[ETH_GSTRING_LEN ]; +size_t size; +size_t offset; }; -#define PCH_GBE_STAT (m) {#m,\ - sizeof(((struct pch_gbe_adapter *)0)->stats.m),\ - offsetof(struct pch_gbe_adapter, stats.m)} + +#define PCH_GBE_STAT (m) \ +{ \ + .string = #m, \ + .size = FIELD_SIZEOF(struct pch_gbe_hw_stats, m), \ + .offset = offsetof(struct pch_gbe_hw_stats, m), \ +} +/** * pch_gbe_gstrings_stats - ethtool information status name list */
@@ -545,7 +550,7 @@ static void pch_gbe_get_strings(struct net_device *netdev, u32 stringset,switch (stringset) {case (u32 )ETH_SS_STATS :for (i =0 ; i <PCH_GBE_GLOBAL_STATS_LEN ; i++) { -memcpy (p, pch_gbe_gstrings_stats[i].stat_string, +memcpy (p, pch_gbe_gstrings_stats[i].string,ETH_GSTRING_LEN ); p +=ETH_GSTRING_LEN ; }
@@ -564,16 +569,15 @@ static void pch_gbe_get_ethtool_stats(struct net_device *netdev, {struct pch_gbe_adapter *adapter =netdev_priv (netdev);int i; +const struct pch_gbe_stats *gstats = pch_gbe_gstrings_stats; +char *hw_stats = (char *)&adapter->stats;FUNC_ENTER ();pch_gbe_update_stats (adapter);for (i =0 ; i <PCH_GBE_GLOBAL_STATS_LEN ; i++) { -signed char *p = - (signed char *)adapter + - pch_gbe_gstrings_stats[i].stat_offset; - data[i] = - (pch_gbe_gstrings_stats[i].sizeof_stat == - (int )sizeof (u64)) ? *(u64 *) p:(*(u32 *) p); +char *p = hw_stats + gstats->offset; + data[i] = gstats->size ==sizeof (u64) ? *(u64 *)p : *(u32 *)p; + gstats++; } }
@@ -614,5 +618,3 @@ void pch_gbe_set_ethtool_ops(struct net_device *netdev) {SET_ETHTOOL_OPS (netdev, &pch_gbe_ethtool_ops); } - -
drivers/net/pch_gbe/pch_gbe_main.c +1 -27
@@ -438,34 +438,8 @@ static int pch_gbe_alloc_queues(struct pch_gbe_adapter *adapter)*/ static void pch_gbe_init_stats (struct pch_gbe_adapter *adapter) { -struct pch_gbe_hw_stats *stats = &adapter->stats; -FUNC_ENTER (); - stats->rx_packets =0 ; - stats->tx_packets =0 ; - stats->rx_bytes =0 ; - stats->tx_bytes =0 ; - stats->rx_errors =0 ; - stats->tx_errors =0 ; - stats->rx_dropped =0 ; - stats->tx_dropped =0 ; - stats->multicast =0 ; - stats->collisions =0 ; - stats->rx_crc_errors =0 ; - stats->rx_frame_errors =0 ; - stats->rx_alloc_buff_failed =0 ; - stats->tx_length_errors =0 ; - stats->tx_aborted_errors =0 ; - stats->tx_carrier_errors =0 ; - stats->tx_timeout_count =0 ; - stats->tx_restart_count =0 ; - stats->intr_rx_dsc_empty_count =0 ; - stats->intr_rx_frame_err_count =0 ; - stats->intr_rx_fifo_err_count =0 ; - stats->intr_rx_dma_err_count =0 ; - stats->intr_tx_fifo_err_count =0 ; - stats->intr_tx_dma_err_count =0 ; - stats->intr_tcpip_err_count =0 ; +memset (&adapter->stats,0 ,sizeof (adapter->stats));return ; }
Re: [PATCH] drivers/net/pch_gbe: Cleanup stats use
drivers/net/pch_gbe/pch_gbe_ethtool.c line 37
Quoted 8 lines · On Tue, 31 Aug 2010 11:38:35 -0700 Joe Perches <[email protected]> wrote:
struct
pch_gbe_stats{drivers/net/pch_gbe/pch_gbe_ethtool.c +3
-3-signed char stat_string[ETH_GSTRING_LEN ]; -int sizeof_stat; -int stat_offset; +signed char string[ETH_GSTRING_LEN ]; +size_t size; +size_t offset; };
Is this driver really using 'signed char' here?
Should just be 'char' for a simple string.
Re: [PATCH] drivers/net/pch_gbe: Cleanup stats use
Quoted 14 lines · Stephen Hemminger
drivers/net/pch_gbe/pch_gbe_ethtool.c line 37
Quoted 8 lines · On Tue, 31 Aug 2010 11:38:35 -0700 Joe Perches <[email protected]> wrote:
struct
pch_gbe_stats{drivers/net/pch_gbe/pch_gbe_ethtool.c +3
-3-signed char stat_string[ETH_GSTRING_LEN ]; -int sizeof_stat; -int stat_offset; +signed char string[ETH_GSTRING_LEN ]; +size_t size; +size_t offset; };Is this driver really using 'signed char' here?
Should just be 'char' for a simple string.
You're right. Probably all the below should just be char.
$ grep -Pn "\bsigned\s+char\b" drivers/net/pch_gbe/*.[ch]
pch_gbe_ethtool.c:34: signed char string[ETH_GSTRING_LEN];
pch_gbe_param.c:155: signed char *name;
pch_gbe_param.c:156: signed char *err;
pch_gbe_param.c:165: struct pch_gbe_opt_list { int i; signed char *str; } *p;Quoted 32 lines · On Tue, 31 Aug 2010 23:15:22 +0900 Masayuki Ohtake <[email protected]>…
Gigabit Ethernet driver of Topcliff PCH
Patch created against 2.6.35Topcliff PCH is the platform controller hub that is going to be used in Intel's upcoming general embedded platform. All IO peripherals in Topcliff PCH are actually devices sitting on AMBA bus. Topcliff PCH has Gigabit Ethernet I/F. Using this I/F, it is able to access system devices connected to Gigabit Ethernet.
Signed-off-by Masayuki Ohtake <[email protected]>--- drivers/net/Kconfig | 10 + drivers/net/Makefile | 1 + drivers/net/pch_gbe/Makefile | 4 + drivers/net/pch_gbe/pch_gbe.h | 683 +++++++++ drivers/net/pch_gbe/pch_gbe_api.c | 246 ++++ drivers/net/pch_gbe/pch_gbe_api.h | 34 + drivers/net/pch_gbe/pch_gbe_ethtool.c | 618 ++++++++ drivers/net/pch_gbe/pch_gbe_main.c | 2591 +++++++++++++++++++++++++++++++++ drivers/net/pch_gbe/pch_gbe_param.c | 519 +++++++ drivers/net/pch_gbe/pch_gbe_phy.c | 276 ++++ drivers/net/pch_gbe/pch_gbe_phy.h | 35 + 11 files changed, 5017 insertions(+), 0 deletions(-) create mode 100644 drivers/net/pch_gbe/Makefile create mode 100644 drivers/net/pch_gbe/pch_gbe.h create mode 100644 drivers/net/pch_gbe/pch_gbe_api.c create mode 100644 drivers/net/pch_gbe/pch_gbe_api.h create mode 100644 drivers/net/pch_gbe/pch_gbe_ethtool.c create mode 100644 drivers/net/pch_gbe/pch_gbe_main.c create mode 100644 drivers/net/pch_gbe/pch_gbe_param.c create mode 100644 drivers/net/pch_gbe/pch_gbe_phy.c create mode 100644 drivers/net/pch_gbe/pch_gbe_phy.h
(snip)
drivers/net/pch_gbe/pch_gbe_main.c line 803
Quoted 13 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +13
-0+/** +* pch_gbe_unmap_and_free_rx_resource - Unmap and free rx socket buffer +* @adapter: Board private structure +* @buffer_info: Buffer information structure +*/ +static void pch_gbe_unmap_and_free_rx_resource ( +struct pch_gbe_adapter *adapter, +struct pch_gbe_buffer *buffer_info) +{ +if (buffer_info->dma) { +pci_unmap_single (adapter->pdev, buffer_info->dma, + buffer_info->length,PCI_DMA_FROMDEVICE ); + buffer_info->dma =0 ;
Probably, this trick doesn't work because zero could be a valid DMA address on some architctures.
drivers/net/pch_gbe/pch_gbe_main.c line 1055
Quoted 5 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +5
-0+/*-- Set Buffer infomation --*/ + buffer_info->length = skb->len; + buffer_info->dma = +pci_map_single (adapter->pdev, skb->data, buffer_info->length, +PCI_DMA_TODEVICE );
Needs to handle mapping failure (dma_mapping_errro)?
I found the same problems in other places.
Can you use dma_map_* API instead of pci_map_*? Please read:
Documentation/DMA-API.txtDocumentation/DMA-API-HOWTO.txt
Thanks,
Hi Fujita
Thank you for your comments.
Quoted 8 lines
Quoted 4 lines
+ if (
buffer_info->dma) {
+ pci_unmap_single(adapter->pdev,buffer_info->dma,
+buffer_info->length,PCI_DMA_FROMDEVICE);
+buffer_info->dma= 0;Probably, this trick doesn't work because zero could be a valid DMA address on some architctures.
The flag which shows mapped will be added. And it is used instead of "if (buffer_info->dma) ".
Quoted 7 lines
drivers/net/pch_gbe/pch_gbe_main.c line 1055
Quoted 5 lines
+ /*-- Set Buffer infomation --*/
+buffer_info->length=skb->len;
+buffer_info->dma=drivers/net/pch_gbe/pch_gbe_main.c new file +2
-0+pci_map_single (adapter->pdev, skb->data, buffer_info->length, +PCI_DMA_TODEVICE );Needs to handle mapping failure (
dma_mapping_errro)?
Error process will be added.
Quoted 2 lines
Can you use dma_map_* API instead of pci_map_*? Please read:
This DMA of device is not standard. Personal use of Gigabit Ethernet device. So, I guess that I do not need to use DMA-API.
Thanks, Ohtake
----- Original Message -----
From: "FUJITA Tomonori" <[email protected]>
To: <[email protected]>
Cc: <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>
Sent: Friday, September 03, 2010 11:23 AM
Subject: Re: [PATCH] Gigabit Ethernet driver of Topcliff PCH
Quoted 75 lines
Quoted 32 lines · On Tue, 31 Aug 2010 23:15:22 +0900 Masayuki Ohtake <[email protected]>…
Gigabit Ethernet driver of Topcliff PCH
Patch created against 2.6.35Topcliff PCH is the platform controller hub that is going to be used in Intel's upcoming general embedded platform. All IO peripherals in Topcliff PCH are actually devices sitting on AMBA bus. Topcliff PCH has Gigabit Ethernet I/F. Using this I/F, it is able to access system devices connected to Gigabit Ethernet.
Signed-off-by Masayuki Ohtake <[email protected]>--- drivers/net/Kconfig | 10 + drivers/net/Makefile | 1 + drivers/net/pch_gbe/Makefile | 4 + drivers/net/pch_gbe/pch_gbe.h | 683 +++++++++ drivers/net/pch_gbe/pch_gbe_api.c | 246 ++++ drivers/net/pch_gbe/pch_gbe_api.h | 34 + drivers/net/pch_gbe/pch_gbe_ethtool.c | 618 ++++++++ drivers/net/pch_gbe/pch_gbe_main.c | 2591 +++++++++++++++++++++++++++++++++ drivers/net/pch_gbe/pch_gbe_param.c | 519 +++++++ drivers/net/pch_gbe/pch_gbe_phy.c | 276 ++++ drivers/net/pch_gbe/pch_gbe_phy.h | 35 + 11 files changed, 5017 insertions(+), 0 deletions(-) create mode 100644 drivers/net/pch_gbe/Makefile create mode 100644 drivers/net/pch_gbe/pch_gbe.h create mode 100644 drivers/net/pch_gbe/pch_gbe_api.c create mode 100644 drivers/net/pch_gbe/pch_gbe_api.h create mode 100644 drivers/net/pch_gbe/pch_gbe_ethtool.c create mode 100644 drivers/net/pch_gbe/pch_gbe_main.c create mode 100644 drivers/net/pch_gbe/pch_gbe_param.c create mode 100644 drivers/net/pch_gbe/pch_gbe_phy.c create mode 100644 drivers/net/pch_gbe/pch_gbe_phy.h(snip)
drivers/net/pch_gbe/pch_gbe_main.c line 803
Quoted 13 lines
drivers/net/pch_gbe/pch_gbe_main.c new file +13
-0+/** +* pch_gbe_unmap_and_free_rx_resource - Unmap and free rx socket buffer +* @adapter: Board private structure +* @buffer_info: Buffer information structure +*/ +static void pch_gbe_unmap_and_free_rx_resource ( +struct pch_gbe_adapter *adapter, +struct pch_gbe_buffer *buffer_info) +{ +if (buffer_info->dma) { +pci_unmap_single (adapter->pdev, buffer_info->dma, + buffer_info->length,PCI_DMA_FROMDEVICE ); + buffer_info->dma =0 ;Probably, this trick doesn't work because zero could be a valid DMA address on some architctures.
drivers/net/pch_gbe/pch_gbe_main.c line 1055
Quoted 5 lines
+ /*-- Set Buffer infomation --*/
+buffer_info->length=skb->len;
+buffer_info->dma=drivers/net/pch_gbe/pch_gbe_main.c new file +2
-0+pci_map_single (adapter->pdev, skb->data, buffer_info->length, +PCI_DMA_TODEVICE );Needs to handle mapping failure (
dma_mapping_errro)?I found the same problems in other places.
Can you use dma_map_* API instead of pci_map_*? Please read:
Documentation/DMA-API.txtDocumentation/DMA-API-HOWTO.txtThanks,
Quoted 6 lines · On Tue, 7 Sep 2010 10:13:22 +0900 "Masayuki Ohtake"…
Quoted 3 lines
Probably, this trick doesn't work because zero could be a valid DMA address on some architctures.
The flag which shows mapped will be added. And it is used instead of "if (
buffer_info->dma) ".
Sounds fine. That's what other drivers do.
Quoted 9 lines
Quoted 7 lines
drivers/net/pch_gbe/pch_gbe_main.c line 1055
Quoted 5 lines
+ /*-- Set Buffer infomation --*/
+buffer_info->length=skb->len;
+buffer_info->dma=drivers/net/pch_gbe/pch_gbe_main.c new file +2
-0+pci_map_single (adapter->pdev, skb->data, buffer_info->length, +PCI_DMA_TODEVICE );Needs to handle mapping failure (
dma_mapping_errro)?Error process will be added.
Nice.
Quoted 5 lines
Quoted 2 lines
Can you use dma_map_* API instead of pci_map_*? Please read:
This DMA of device is not standard. Personal use of Gigabit Ethernet device. So, I guess that I do not need to use DMA-API.
Sorry, I'm not sure what you mean. If a driver does DMA, it must use the DMA API. Your driver already uses the DMA API (pci_dma_*), however, pci_map_* API is obsolete so please use dma_map_* API instead.
Thanks,
Hi Fujita
Quoted 7 lines
Quoted 2 lines
This DMA of device is not standard. Personal use of Gigabit Ethernet device. So, I guess that I do not need to use DMA-API.
Sorry, I'm not sure what you mean. If a driver does DMA, it must use the DMA API. Your driver already uses the DMA API (pci_dma_*), however, pci_map_* API is obsolete so please use dma_map_* API instead.
Thank you for the explanation.
I understood and use dma_map_* .
Thanks Ohtake
----- Original Message -----
From: "FUJITA Tomonori" <[email protected]>
To: <[email protected]>
Cc: <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>
Sent: Tuesday, September 07, 2010 12:21 PM
Subject: Re: [PATCH] Gigabit Ethernet driver of Topcliff PCH
Quoted 43 lines
Quoted 6 lines · On Tue, 7 Sep 2010 10:13:22 +0900 "Masayuki Ohtake"…
Quoted 3 lines
Probably, this trick doesn't work because zero could be a valid DMA address on some architctures.
The flag which shows mapped will be added. And it is used instead of "if (
buffer_info->dma) ".Sounds fine. That's what other drivers do.
Quoted 9 lines
Quoted 7 lines
drivers/net/pch_gbe/pch_gbe_main.c line 1055
Quoted 5 lines
+ /*-- Set Buffer infomation --*/
+buffer_info->length=skb->len;
+buffer_info->dma=drivers/net/pch_gbe/pch_gbe_main.c new file +2
-0+pci_map_single (adapter->pdev, skb->data, buffer_info->length, +PCI_DMA_TODEVICE );Needs to handle mapping failure (
dma_mapping_errro)?Error process will be added.
Nice.
Quoted 5 lines
Quoted 2 lines
Can you use dma_map_* API instead of pci_map_*? Please read:
This DMA of device is not standard. Personal use of Gigabit Ethernet device. So, I guess that I do not need to use DMA-API.
Sorry, I'm not sure what you mean. If a driver does DMA, it must use the DMA API. Your driver already uses the DMA API (pci_dma_*), however, pci_map_* API is obsolete so please use dma_map_* API instead.
Thanks,
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html