提交 f4983704 编写于 作者: S Sandeep Gopalpet 提交者: David S. Miller

gianfar: Introduce logical group support.

This patch introduces the group structure. The elements of this
structure are the interrupt lines, their corresponding names,
the register memory map.
The elements for this group are factored out from the gfar_private
structure. The introduction of group structure will help in
providing support for newer versions of etsec.

Currently, the support is present only for single group and
single tx/rx queues.
Signed-off-by: NSandeep Gopalpet <Sandeep.Kumar@freescale.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a12f801d
此差异已折叠。
......@@ -770,6 +770,32 @@ struct gfar_priv_rx_q {
unsigned long rxic;
};
/**
* struct gfar_priv_grp - per group structure
* @priv: back pointer to the priv structure
* @regs: the ioremapped register space for this group
* @grp_id: group id for this group
* @interruptTransmit: The TX interrupt number for this group
* @interruptReceive: The RX interrupt number for this group
* @interruptError: The ERROR interrupt number for this group
* @int_name_tx: tx interrupt name for this group
* @int_name_rx: rx interrupt name for this group
* @int_name_er: er interrupt name for this group
*/
struct gfar_priv_grp {
spinlock_t grplock __attribute__ ((aligned (SMP_CACHE_BYTES)));
struct gfar_private *priv;
struct gfar __iomem *regs;
unsigned int interruptTransmit;
unsigned int interruptReceive;
unsigned int interruptError;
char int_name_tx[GFAR_INT_NAME_MAX];
char int_name_rx[GFAR_INT_NAME_MAX];
char int_name_er[GFAR_INT_NAME_MAX];
};
/* Struct stolen almost completely (and shamelessly) from the FCC enet source
* (Ok, that's not so true anymore, but there is a family resemblence)
* The GFAR buffer descriptors track the ring buffers. The rx_bd_base
......@@ -785,6 +811,7 @@ struct gfar_private {
struct net_device *ndev;
struct of_device *ofdev;
struct gfar_priv_grp gfargrp;
struct gfar_priv_tx_q *tx_queue;
struct gfar_priv_rx_q *rx_queue;
......@@ -797,9 +824,6 @@ struct gfar_private {
struct vlan_group *vlgrp;
/* Unprotected fields */
/* Pointer to the GFAR memory mapped Registers */
struct gfar __iomem *regs;
/* Hash registers and their width */
u32 __iomem *hash_regs[16];
......@@ -823,10 +847,6 @@ struct gfar_private {
wol_en:1; /* Wake-on-LAN enabled */
unsigned short padding;
unsigned int interruptTransmit;
unsigned int interruptReceive;
unsigned int interruptError;
/* PHY stuff */
struct phy_device *phydev;
struct mii_bus *mii_bus;
......@@ -838,10 +858,6 @@ struct gfar_private {
struct work_struct reset_task;
char int_name_tx[GFAR_INT_NAME_MAX];
char int_name_rx[GFAR_INT_NAME_MAX];
char int_name_er[GFAR_INT_NAME_MAX];
/* Network Statistics */
struct gfar_extra_stats extra_stats;
};
......
......@@ -137,10 +137,11 @@ static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
{
int i;
struct gfar_private *priv = netdev_priv(dev);
struct gfar __iomem *regs = priv->gfargrp.regs;
u64 *extra = (u64 *) & priv->extra_stats;
if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
u32 __iomem *rmon = (u32 __iomem *) & priv->regs->rmon;
u32 __iomem *rmon = (u32 __iomem *) &regs->rmon;
struct gfar_stats *stats = (struct gfar_stats *) buf;
for (i = 0; i < GFAR_RMON_LEN; i++)
......@@ -223,7 +224,7 @@ static void gfar_get_regs(struct net_device *dev, struct ethtool_regs *regs, voi
{
int i;
struct gfar_private *priv = netdev_priv(dev);
u32 __iomem *theregs = (u32 __iomem *) priv->regs;
u32 __iomem *theregs = (u32 __iomem *) priv->gfargrp.regs;
u32 *buf = (u32 *) regbuf;
for (i = 0; i < sizeof (struct gfar) / sizeof (u32); i++)
......@@ -349,6 +350,7 @@ static int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals
static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals)
{
struct gfar_private *priv = netdev_priv(dev);
struct gfar __iomem *regs = priv->gfargrp.regs;
struct gfar_priv_tx_q *tx_queue = NULL;
struct gfar_priv_rx_q *rx_queue = NULL;
......@@ -407,13 +409,13 @@ static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals
tx_queue->txic = mk_ic_value(cvals->tx_max_coalesced_frames,
gfar_usecs2ticks(priv, cvals->tx_coalesce_usecs));
gfar_write(&priv->regs->rxic, 0);
gfar_write(&regs->rxic, 0);
if (rx_queue->rxcoalescing)
gfar_write(&priv->regs->rxic, rx_queue->rxic);
gfar_write(&regs->rxic, rx_queue->rxic);
gfar_write(&priv->regs->txic, 0);
gfar_write(&regs->txic, 0);
if (tx_queue->txcoalescing)
gfar_write(&priv->regs->txic, tx_queue->txic);
gfar_write(&regs->txic, tx_queue->txic);
return 0;
}
......
......@@ -50,6 +50,7 @@ static ssize_t gfar_set_bd_stash(struct device *dev,
const char *buf, size_t count)
{
struct gfar_private *priv = netdev_priv(to_net_dev(dev));
struct gfar __iomem *regs = priv->gfargrp.regs;
struct gfar_priv_rx_q *rx_queue = NULL;
int new_setting = 0;
u32 temp;
......@@ -74,14 +75,14 @@ static ssize_t gfar_set_bd_stash(struct device *dev,
/* Set the new stashing value */
priv->bd_stash_en = new_setting;
temp = gfar_read(&priv->regs->attr);
temp = gfar_read(&regs->attr);
if (new_setting)
temp |= ATTR_BDSTASH;
else
temp &= ~(ATTR_BDSTASH);
gfar_write(&priv->regs->attr, temp);
gfar_write(&regs->attr, temp);
spin_unlock_irqrestore(&rx_queue->rxlock, flags);
......@@ -103,6 +104,7 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
const char *buf, size_t count)
{
struct gfar_private *priv = netdev_priv(to_net_dev(dev));
struct gfar __iomem *regs = priv->gfargrp.regs;
struct gfar_priv_rx_q *rx_queue = NULL;
unsigned int length = simple_strtoul(buf, NULL, 0);
u32 temp;
......@@ -122,20 +124,20 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
priv->rx_stash_size = length;
temp = gfar_read(&priv->regs->attreli);
temp = gfar_read(&regs->attreli);
temp &= ~ATTRELI_EL_MASK;
temp |= ATTRELI_EL(length);
gfar_write(&priv->regs->attreli, temp);
gfar_write(&regs->attreli, temp);
/* Turn stashing on/off as appropriate */
temp = gfar_read(&priv->regs->attr);
temp = gfar_read(&regs->attr);
if (length)
temp |= ATTR_BUFSTASH;
else
temp &= ~(ATTR_BUFSTASH);
gfar_write(&priv->regs->attr, temp);
gfar_write(&regs->attr, temp);
out:
spin_unlock_irqrestore(&rx_queue->rxlock, flags);
......@@ -161,6 +163,7 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
const char *buf, size_t count)
{
struct gfar_private *priv = netdev_priv(to_net_dev(dev));
struct gfar __iomem *regs = priv->gfargrp.regs;
struct gfar_priv_rx_q *rx_queue = NULL;
unsigned short index = simple_strtoul(buf, NULL, 0);
u32 temp;
......@@ -180,10 +183,10 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
priv->rx_stash_index = index;
temp = gfar_read(&priv->regs->attreli);
temp = gfar_read(&regs->attreli);
temp &= ~ATTRELI_EI_MASK;
temp |= ATTRELI_EI(index);
gfar_write(&priv->regs->attreli, flags);
gfar_write(&regs->attreli, flags);
out:
spin_unlock_irqrestore(&rx_queue->rxlock, flags);
......@@ -208,6 +211,7 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev,
const char *buf, size_t count)
{
struct gfar_private *priv = netdev_priv(to_net_dev(dev));
struct gfar __iomem *regs = priv->gfargrp.regs;
struct gfar_priv_tx_q *tx_queue = NULL;
unsigned int length = simple_strtoul(buf, NULL, 0);
u32 temp;
......@@ -222,10 +226,10 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev,
priv->fifo_threshold = length;
temp = gfar_read(&priv->regs->fifo_tx_thr);
temp = gfar_read(&regs->fifo_tx_thr);
temp &= ~FIFO_TX_THR_MASK;
temp |= length;
gfar_write(&priv->regs->fifo_tx_thr, temp);
gfar_write(&regs->fifo_tx_thr, temp);
spin_unlock_irqrestore(&tx_queue->txlock, flags);
......@@ -248,6 +252,7 @@ static ssize_t gfar_set_fifo_starve(struct device *dev,
const char *buf, size_t count)
{
struct gfar_private *priv = netdev_priv(to_net_dev(dev));
struct gfar __iomem *regs = priv->gfargrp.regs;
struct gfar_priv_tx_q *tx_queue = NULL;
unsigned int num = simple_strtoul(buf, NULL, 0);
u32 temp;
......@@ -261,10 +266,10 @@ static ssize_t gfar_set_fifo_starve(struct device *dev,
priv->fifo_starve = num;
temp = gfar_read(&priv->regs->fifo_tx_starve);
temp = gfar_read(&regs->fifo_tx_starve);
temp &= ~FIFO_TX_STARVE_MASK;
temp |= num;
gfar_write(&priv->regs->fifo_tx_starve, temp);
gfar_write(&regs->fifo_tx_starve, temp);
spin_unlock_irqrestore(&tx_queue->txlock, flags);
......@@ -288,6 +293,7 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev,
const char *buf, size_t count)
{
struct gfar_private *priv = netdev_priv(to_net_dev(dev));
struct gfar __iomem *regs = priv->gfargrp.regs;
struct gfar_priv_tx_q *tx_queue = NULL;
unsigned int num = simple_strtoul(buf, NULL, 0);
u32 temp;
......@@ -301,10 +307,10 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev,
priv->fifo_starve_off = num;
temp = gfar_read(&priv->regs->fifo_tx_starve_shutoff);
temp = gfar_read(&regs->fifo_tx_starve_shutoff);
temp &= ~FIFO_TX_STARVE_OFF_MASK;
temp |= num;
gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp);
gfar_write(&regs->fifo_tx_starve_shutoff, temp);
spin_unlock_irqrestore(&tx_queue->txlock, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册