From: Zang Roy-r61911 <tie-fei.zang@freescale.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Andrew Morton <akpm@osdl.org>, netdev <netdev@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [patch 3/3] Add tsi108 On Chip Ethernet device driver support
Date: 29 Sep 2006 15:36:46 +0800 [thread overview]
Message-ID: <1159515406.13634.2.camel@localhost.localdomain> (raw)
In-Reply-To: <45121924.4000200@pobox.com>
On Thu, 2006-09-21 at 12:46, Jeff Garzik wrote:
> Zang Roy-r61911 wrote:
> > +struct tsi108_prv_data {
> > + void __iomem *regs; /* Base of normal regs */
> > + void __iomem *phyregs; /* Base of register bank used for PHY
> access */
> > +
> > + int phy; /* Index of PHY for this interface */
> > + int irq_num;
> > + int id;
> > +
> > + struct timer_list timer;/* Timer that triggers the check phy
> function */
> > + int rxtail; /* Next entry in rxring to read */
> > + int rxhead; /* Next entry in rxring to give a new
> buffer */
> > + int rxfree; /* Number of free, allocated RX
> buffers */
> > +
> > + int rxpending; /* Non-zero if there are still
> descriptors
> > + * to be processed from a previous
> descriptor
> > + * interrupt condition that has been
> cleared */
> > +
> > + int txtail; /* Next TX descriptor to check status
> on */
> > + int txhead; /* Next TX descriptor to use */
>
> most of these should be unsigned, to prevent bugs.
>
>
> > + /* Number of free TX descriptors. This could be calculated
> from
> > + * rxhead and rxtail if one descriptor were left unused to
> disambiguate
> > + * full and empty conditions, but it's simpler to just keep
> track
> > + * explicitly. */
> > +
> > + int txfree;
> > +
> > + int phy_ok; /* The PHY is currently powered on. */
> > +
> > + /* PHY status (duplex is 1 for half, 2 for full,
> > + * so that the default 0 indicates that neither has
> > + * yet been configured). */
> > +
> > + int link_up;
> > + int speed;
> > + int duplex;
> > +
> > + tx_desc *txring;
> > + rx_desc *rxring;
> > + struct sk_buff *txskbs[TSI108_TXRING_LEN];
> > + struct sk_buff *rxskbs[TSI108_RXRING_LEN];
> > +
> > + dma_addr_t txdma, rxdma;
> > +
> > + /* txlock nests in misclock and phy_lock */
> > +
> > + spinlock_t txlock, misclock;
> > +
> > + /* stats is used to hold the upper bits of each hardware
> counter,
> > + * and tmpstats is used to hold the full values for returning
> > + * to the caller of get_stats(). They must be separate in
> case
> > + * an overflow interrupt occurs before the stats are consumed.
> > + */
> > +
> > + struct net_device_stats stats;
> > + struct net_device_stats tmpstats;
> > +
> > + /* These stats are kept separate in hardware, thus require
> individual
> > + * fields for handling carry. They are combined in get_stats.
> > + */
> > +
> > + unsigned long rx_fcs; /* Add to rx_frame_errors */
> > + unsigned long rx_short_fcs; /* Add to rx_frame_errors */
> > + unsigned long rx_long_fcs; /* Add to rx_frame_errors */
> > + unsigned long rx_underruns; /* Add to rx_length_errors */
> > + unsigned long rx_overruns; /* Add to rx_length_errors */
> > +
> > + unsigned long tx_coll_abort; /* Add to
> tx_aborted_errors/collisions */
> > + unsigned long tx_pause_drop; /* Add to tx_aborted_errors */
> > +
> > + unsigned long mc_hash[16];
> > +};
> > +
> > +/* Structure for a device driver */
> > +
> > +static struct platform_driver tsi_eth_driver = {
> > + .probe = tsi108_init_one,
> > + .remove = tsi108_ether_remove,
> > + .driver = {
> > + .name = "tsi-ethernet",
> > + },
> > +};
> > +
> > +static void tsi108_timed_checker(unsigned long dev_ptr);
> > +
> > +static void dump_eth_one(struct net_device *dev)
> > +{
> > + struct tsi108_prv_data *data = netdev_priv(dev);
> > +
> > + printk("Dumping %s...\n", dev->name);
> > + printk("intstat %x intmask %x phy_ok %d"
> > + " link %d speed %d duplex %d\n",
> > + TSI108_ETH_READ_REG(TSI108_EC_INTSTAT),
> > + TSI108_ETH_READ_REG(TSI108_EC_INTMASK), data->phy_ok,
> > + data->link_up, data->speed, data->duplex);
> > +
> > + printk("TX: head %d, tail %d, free %d, stat %x, estat %x, err
> %x\n",
> > + data->txhead, data->txtail, data->txfree,
> > + TSI108_ETH_READ_REG(TSI108_EC_TXSTAT),
> > + TSI108_ETH_READ_REG(TSI108_EC_TXESTAT),
> > + TSI108_ETH_READ_REG(TSI108_EC_TXERR));
> > +
> > + printk("RX: head %d, tail %d, free %d, stat %x,"
> > + " estat %x, err %x, pending %d\n\n",
> > + data->rxhead, data->rxtail, data->rxfree,
> > + TSI108_ETH_READ_REG(TSI108_EC_RXSTAT),
> > + TSI108_ETH_READ_REG(TSI108_EC_RXESTAT),
> > + TSI108_ETH_READ_REG(TSI108_EC_RXERR), data->rxpending);
> > +}
> > +
> > +/* Synchronization is needed between the thread and up/down events.
> > + * Note that the PHY is accessed through the same registers for
> both
> > + * interfaces, so this can't be made interface-specific.
> > + */
> > +
> > +static DEFINE_SPINLOCK(phy_lock);
>
> you should have a chip structure, that contains two structs (one for
> each interface/port)
>
>
Could you interpret the chip structure in more detail?
Need I create two net_device struct for each port?
Thanks.
Roy
next prev parent reply other threads:[~2006-09-29 7:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <A0CDBA58F226D911B202000BDBAD46730A1B1410@zch01exm23.fsl.freescale.net>
[not found] ` <1157962200.10526.10.camel@localhost.localdomain>
2006-09-12 8:55 ` [patch 0/3] Add tsi108 On chip Ethernet device driver support Zang Roy-r61911
2006-09-21 4:04 ` [patch 0/3 v2] " Zang Roy-r61911
2006-09-12 8:55 ` [patch 1/3] Add tsi108 on Chip " Zang Roy-r61911
2006-09-21 4:04 ` [patch 1/3 v2] Add tsi108 On " Zang Roy-r61911
2006-09-12 8:55 ` [patch 3/3] " Zang Roy-r61911
2006-09-12 10:07 ` Arjan van de Ven
2006-09-19 7:39 ` Zang Roy-r61911
2006-09-20 8:45 ` Arjan van de Ven
2006-09-12 14:33 ` Roland Dreier
2006-09-12 14:43 ` Jeff Garzik
2006-09-14 2:51 ` Zang Roy-r61911
[not found] ` <1158749825.7973.9.camel@localhost.localdomain>
2006-09-21 4:26 ` Jeff Garzik
2006-09-21 5:46 ` Zang Roy-r61911
2006-09-21 6:30 ` Jeff Garzik
2006-09-21 4:46 ` Jeff Garzik
2006-09-29 7:36 ` Zang Roy-r61911 [this message]
2006-09-29 7:47 ` Jeff Garzik
2006-10-17 7:18 ` Zang Roy-r61911
2006-10-30 5:19 ` Add tsi108/9 " Zang Roy-r61911
2006-10-31 2:26 ` [PATCH] " Zang Roy-r61911
2006-10-23 2:09 ` [patch 3/3] Add tsi108 " Zang Roy-r61911
2006-10-26 2:50 ` Zang Roy-r61911
2006-09-21 4:05 ` [patch 3/3 v2] " Zang Roy-r61911
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=1159515406.13634.2.camel@localhost.localdomain \
--to=tie-fei.zang@freescale.com \
--cc=akpm@osdl.org \
--cc=jgarzik@pobox.com \
--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).