From: Arnd Bergmann <arnd@arndb.de>
To: GuanXuetao <gxt@mprc.pku.edu.cn>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
greg@kroah.com, netdev@vger.kernel.org
Subject: Re: [PATCH 2/6] unicore32: add pkunity-v3 mac/net driver (umal)
Date: Fri, 27 May 2011 11:19:41 +0200 [thread overview]
Message-ID: <201105271119.41323.arnd@arndb.de> (raw)
In-Reply-To: <556924396ee34f4af94a2f03767973f1cec35e22.1306408804.git.gxt@mprc.pku.edu.cn>
On Thursday 26 May 2011, GuanXuetao wrote:
> From: Guan Xuetao <gxt@mprc.pku.edu.cn>
>
> Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
> ---
> MAINTAINERS | 1 +
> arch/unicore32/configs/debug_defconfig | 2 +-
> drivers/net/Kconfig | 5 +
> drivers/net/Makefile | 1 +
> drivers/net/mac-puv3.c | 1942 ++++++++++++++++++++++++++++++++
> 5 files changed, 1950 insertions(+), 1 deletions(-)
> create mode 100644 drivers/net/mac-puv3.c
I also have a few comments after looking through the driver.
> +
> +/**********************************************************************
> + * Globals
> + ********************************************************************* */
Regular commenting style would be
/*
* Globals
*/
> +/**********************************************************************
> + * Prototypes
> + ********************************************************************* */
> +static int umal_mii_reset(struct mii_bus *bus);
> +static int umal_mii_read(struct mii_bus *bus, int phyaddr, int regidx);
> +static int umal_mii_write(struct mii_bus *bus, int phyaddr, int regidx,
> + u16 val);
> +static int umal_mii_probe(struct net_device *dev);
> +
> +static void umaldma_initctx(struct umaldma *d, struct umal_softc *s,
> + int rxtx, int maxdescr);
> +static void umaldma_uninitctx(struct umaldma *d);
> +static void umaldma_channel_start(struct umaldma *d, int rxtx);
> +static void umaldma_channel_stop(struct umaldma *d);
> +static int umaldma_add_rcvbuffer(struct umal_softc *sc, struct umaldma *d,
> + struct sk_buff *m);
> +static int umaldma_add_txbuffer(struct umaldma *d, struct sk_buff *m);
> +static void umaldma_emptyring(struct umaldma *d);
> +static void umaldma_fillring(struct umal_softc *sc, struct umaldma *d);
> +static int umaldma_rx_process(struct umal_softc *sc, struct umaldma *d,
> + int work_to_do, int poll);
> +static void umaldma_tx_process(struct umal_softc *sc, struct umaldma *d,
> + int poll);
> +
> +static int umal_initctx(struct umal_softc *s);
> +static void umal_uninitctx(struct umal_softc *s);
> +static void umal_channel_start(struct umal_softc *s);
> +static void umal_channel_stop(struct umal_softc *s);
> +static enum umal_state umal_set_channel_state(struct umal_softc *,
> + enum umal_state);
> +
> +static int umal_init(struct platform_device *pldev, long long base);
> +static int umal_open(struct net_device *dev);
> +static int umal_close(struct net_device *dev);
> +static int umal_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
> +static irqreturn_t umal_intr(int irq, void *dev_instance);
> +static void umal_clr_intr(struct net_device *dev);
> +static int umal_start_tx(struct sk_buff *skb, struct net_device *dev);
> +static void umal_tx_timeout(struct net_device *dev);
> +static void umal_set_rx_mode(struct net_device *dev);
> +static void umal_promiscuous_mode(struct umal_softc *sc, int onoff);
> +static void umal_setmulti(struct umal_softc *sc);
> +static int umal_set_speed(struct umal_softc *s, enum umal_speed speed);
> +static int umal_set_duplex(struct umal_softc *s, enum umal_duplex duplex,
> + enum umal_fc fc);
> +static int umal_change_mtu(struct net_device *_dev, int new_mtu);
> +static void umal_miipoll(struct net_device *dev);
Best avoid all these prototypes. Instead, reorder the functions in the
driver so you don't need them. That is the order in which reviewers expect
them.
> +/**********************************************************************
> + * UMAL_MII_RESET(bus)
> + *
> + * Reset MII bus.
> + *
> + * Input parameters:
> + * bus - MDIO bus handle
> + *
> + * Return value:
> + * 0 if ok
> + ********************************************************************* */
For extended function documentation, use the kerneldoc style, e.g.
/**
* umal_mii_reset - reset MII bus
*
* @bus: MDIO bus handle
*
* Returns 0
*/
See also Documentation/kernel-doc-nano-HOWTO.txt
> +/**********************************************************************
> + * UMALDMA_RX_PROCESS(sc,d,work_to_do,poll)
> + *
> + * Process "completed" receive buffers on the specified DMA channel.
> + *
> + * Input parameters:
> + * sc - softc structure
> + * d - DMA channel context
> + * work_to_do - no. of packets to process before enabling interrupt
> + * again (for NAPI)
> + * poll - 1: using polling (for NAPI)
> + *
> + * Return value:
> + * nothing
> + ********************************************************************* */
> +static int umaldma_rx_process(struct umal_softc *sc, struct umaldma *d,
> + int work_to_do, int poll)
It seems that you tried to convert the driver to NAPI but did not succeed,
as this function is only called from the interrupt handler directly.
There is usually a significant performance win from using NAPI, so you
should better try again. If you had problems doing that, please ask
on netdev.
> +
> +#ifdef CONFIG_CMDLINE_FORCE
> + eaddr[0] = 0x00;
> + eaddr[1] = 0x25;
> + eaddr[2] = 0x9b;
> + eaddr[3] = 0xff;
> + eaddr[4] = 0x00;
> + eaddr[5] = 0x00;
> +#endif
> +
> + for (i = 0; i < 6; i++)
> + dev->dev_addr[i] = eaddr[i];
You can use random_ether_addr() to generate a working unique MAC address
if the hardware does not provide one.
Arnd
next prev parent reply other threads:[~2011-05-27 9:19 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-26 11:36 [PATCH 0/6] unicore32 subsystem: 6 patches for 2.6.39 GuanXuetao
2011-05-26 11:36 ` [PATCH 1/6] unicore32: move rtc-puv3.c to drivers/rtc directory GuanXuetao
2011-05-26 12:40 ` Arnd Bergmann
2011-05-27 3:04 ` Guan Xuetao
2011-05-26 11:36 ` [PATCH 2/6] unicore32: add pkunity-v3 mac/net driver (umal) GuanXuetao
2011-05-26 11:36 ` GuanXuetao
2011-05-26 12:43 ` Arnd Bergmann
2011-05-27 3:08 ` Guan Xuetao
2011-05-27 3:08 ` Guan Xuetao
2011-05-26 17:56 ` Ben Hutchings
2011-05-27 4:27 ` Guan Xuetao
2011-05-27 9:19 ` Arnd Bergmann [this message]
2011-05-28 2:52 ` Guan Xuetao
2011-05-26 11:36 ` [PATCH 3/6] unicore32: change zImage physical address, though it's PIC codes GuanXuetao
2011-05-26 11:36 ` GuanXuetao
2011-05-26 12:44 ` Arnd Bergmann
2011-05-26 11:36 ` [PATCH 4/6] unicore32: add KBUILD_DEFCONFIG with unicore32_defconfig (old debug_defconfig) GuanXuetao
2011-05-26 11:36 ` GuanXuetao
2011-05-26 12:45 ` Arnd Bergmann
2011-05-26 11:36 ` [PATCH 5/6] unicore32: change PERCPU to PERCPU_SECTION GuanXuetao
2011-05-26 11:46 ` Tejun Heo
2011-05-26 11:36 ` [PATCH 6/6] unicore32: using generic-y format for one line asm-generic files GuanXuetao
2011-05-26 11:36 ` GuanXuetao
2011-05-26 12:45 ` Arnd Bergmann
2011-05-26 12:45 ` Arnd Bergmann
2011-05-27 3:24 ` Guan Xuetao
2011-05-26 12:50 ` [PATCH 0/6] unicore32 subsystem: 6 patches for 2.6.39 Arnd Bergmann
2011-05-27 2:58 ` Guan Xuetao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201105271119.41323.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=greg@kroah.com \
--cc=gxt@mprc.pku.edu.cn \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).