Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 183462
b: refs/heads/master
c: db98a0b
h: refs/heads/master
v: v3
  • Loading branch information
Giuseppe CAVALLARO authored and David S. Miller committed Jan 8, 2010
1 parent 4d83c6e commit 2f84812
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 147 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 65818fa744e70a58d230083dda1f1cd8e5c5e2ee
refs/heads/master: db98a0b001df79ffcdd4f231c3516411786a1113
64 changes: 34 additions & 30 deletions trunk/drivers/net/stmmac/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,11 @@ static inline void stmmac_get_mac_addr(unsigned long ioaddr,
return;
}

struct stmmac_ops {
/* MAC core initialization */
void (*core_init) (unsigned long ioaddr) ____cacheline_aligned;
/* DMA core initialization */
int (*dma_init) (unsigned long ioaddr, int pbl, u32 dma_tx, u32 dma_rx);
/* Dump MAC registers */
void (*dump_mac_regs) (unsigned long ioaddr);
/* Dump DMA registers */
void (*dump_dma_regs) (unsigned long ioaddr);
/* Set tx/rx threshold in the csr6 register
* An invalid value enables the store-and-forward mode */
void (*dma_mode) (unsigned long ioaddr, int txmode, int rxmode);
/* To track extra statistic (if supported) */
void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x,
unsigned long ioaddr);
/* RX descriptor ring initialization */
struct stmmac_desc_ops {
/* DMA RX descriptor ring initialization */
void (*init_rx_desc) (struct dma_desc *p, unsigned int ring_size,
int disable_rx_ic);
/* TX descriptor ring initialization */
int disable_rx_ic);
/* DMA TX descriptor ring initialization */
void (*init_tx_desc) (struct dma_desc *p, unsigned int ring_size);

/* Invoked by the xmit function to prepare the tx descriptor */
Expand All @@ -281,14 +267,35 @@ struct stmmac_ops {
/* Get the buffer size from the descriptor */
int (*get_tx_len) (struct dma_desc *p);
/* Handle extra events on specific interrupts hw dependent */
void (*host_irq_status) (unsigned long ioaddr);
int (*get_rx_owner) (struct dma_desc *p);
void (*set_rx_owner) (struct dma_desc *p);
/* Get the receive frame size */
int (*get_rx_frame_len) (struct dma_desc *p);
/* Return the reception status looking at the RDES1 */
int (*rx_status) (void *data, struct stmmac_extra_stats *x,
struct dma_desc *p);
};

struct stmmac_dma_ops {
/* DMA core initialization */
int (*init) (unsigned long ioaddr, int pbl, u32 dma_tx, u32 dma_rx);
/* Dump DMA registers */
void (*dump_regs) (unsigned long ioaddr);
/* Set tx/rx threshold in the csr6 register
* An invalid value enables the store-and-forward mode */
void (*dma_mode) (unsigned long ioaddr, int txmode, int rxmode);
/* To track extra statistic (if supported) */
void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x,
unsigned long ioaddr);
};

struct stmmac_ops {
/* MAC core initialization */
void (*core_init) (unsigned long ioaddr) ____cacheline_aligned;
/* Dump MAC registers */
void (*dump_regs) (unsigned long ioaddr);
/* Handle extra events on specific interrupts hw dependent */
void (*host_irq_status) (unsigned long ioaddr);
/* Multicast filter setting */
void (*set_filter) (struct net_device *dev);
/* Flow control setting */
Expand All @@ -298,9 +305,9 @@ struct stmmac_ops {
void (*pmt) (unsigned long ioaddr, unsigned long mode);
/* Set/Get Unicast MAC addresses */
void (*set_umac_addr) (unsigned long ioaddr, unsigned char *addr,
unsigned int reg_n);
unsigned int reg_n);
void (*get_umac_addr) (unsigned long ioaddr, unsigned char *addr,
unsigned int reg_n);
unsigned int reg_n);
};

struct mac_link {
Expand All @@ -314,16 +321,13 @@ struct mii_regs {
unsigned int data; /* MII Data */
};

struct hw_cap {
unsigned int version; /* Core Version register (GMAC) */
unsigned int pmt; /* Power-Down mode (GMAC) */
struct mac_link link;
struct mii_regs mii;
};

struct mac_device_info {
struct hw_cap hw;
struct stmmac_ops *ops;
struct stmmac_ops *mac;
struct stmmac_desc_ops *desc;
struct stmmac_dma_ops *dma;
unsigned int pmt; /* support Power-Down */
struct mii_regs mii; /* MII register Addresses */
struct mac_link link;
};

struct mac_device_info *gmac_setup(unsigned long addr);
Expand Down
43 changes: 26 additions & 17 deletions trunk/drivers/net/stmmac/gmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,19 +630,28 @@ static int gmac_get_rx_frame_len(struct dma_desc *p)
return p->des01.erx.frame_length;
}

struct stmmac_ops gmac_driver = {
struct stmmac_ops gmac_ops = {
.core_init = gmac_core_init,
.dump_mac_regs = gmac_dump_regs,
.dma_init = gmac_dma_init,
.dump_dma_regs = gmac_dump_dma_regs,
.dump_regs = gmac_dump_regs,
.host_irq_status = gmac_irq_status,
.set_filter = gmac_set_filter,
.flow_ctrl = gmac_flow_ctrl,
.pmt = gmac_pmt,
.set_umac_addr = gmac_set_umac_addr,
.get_umac_addr = gmac_get_umac_addr,
};

struct stmmac_dma_ops gmac_dma_ops = {
.init = gmac_dma_init,
.dump_regs = gmac_dump_dma_regs,
.dma_mode = gmac_dma_operation_mode,
.dma_diagnostic_fr = gmac_dma_diagnostic_fr,
};

struct stmmac_desc_ops gmac_desc_ops = {
.tx_status = gmac_get_tx_frame_status,
.rx_status = gmac_get_rx_frame_status,
.get_tx_len = gmac_get_tx_len,
.set_filter = gmac_set_filter,
.flow_ctrl = gmac_flow_ctrl,
.pmt = gmac_pmt,
.init_rx_desc = gmac_init_rx_desc,
.init_tx_desc = gmac_init_tx_desc,
.get_tx_owner = gmac_get_tx_owner,
Expand All @@ -655,9 +664,6 @@ struct stmmac_ops gmac_driver = {
.set_tx_owner = gmac_set_tx_owner,
.set_rx_owner = gmac_set_rx_owner,
.get_rx_frame_len = gmac_get_rx_frame_len,
.host_irq_status = gmac_irq_status,
.set_umac_addr = gmac_set_umac_addr,
.get_umac_addr = gmac_get_umac_addr,
};

struct mac_device_info *gmac_setup(unsigned long ioaddr)
Expand All @@ -670,13 +676,16 @@ struct mac_device_info *gmac_setup(unsigned long ioaddr)

mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL);

mac->ops = &gmac_driver;
mac->hw.pmt = PMT_SUPPORTED;
mac->hw.link.port = GMAC_CONTROL_PS;
mac->hw.link.duplex = GMAC_CONTROL_DM;
mac->hw.link.speed = GMAC_CONTROL_FES;
mac->hw.mii.addr = GMAC_MII_ADDR;
mac->hw.mii.data = GMAC_MII_DATA;
mac->mac = &gmac_ops;
mac->desc = &gmac_desc_ops;
mac->dma = &gmac_dma_ops;

mac->pmt = PMT_SUPPORTED;
mac->link.port = GMAC_CONTROL_PS;
mac->link.duplex = GMAC_CONTROL_DM;
mac->link.speed = GMAC_CONTROL_FES;
mac->mii.addr = GMAC_MII_ADDR;
mac->mii.data = GMAC_MII_DATA;

return mac;
}
43 changes: 26 additions & 17 deletions trunk/drivers/net/stmmac/mac100.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,19 +467,28 @@ static int mac100_get_rx_frame_len(struct dma_desc *p)
return p->des01.rx.frame_length;
}

struct stmmac_ops mac100_driver = {
struct stmmac_ops mac100_ops = {
.core_init = mac100_core_init,
.dump_mac_regs = mac100_dump_mac_regs,
.dma_init = mac100_dma_init,
.dump_dma_regs = mac100_dump_dma_regs,
.dump_regs = mac100_dump_mac_regs,
.host_irq_status = mac100_irq_status,
.set_filter = mac100_set_filter,
.flow_ctrl = mac100_flow_ctrl,
.pmt = mac100_pmt,
.set_umac_addr = mac100_set_umac_addr,
.get_umac_addr = mac100_get_umac_addr,
};

struct stmmac_dma_ops mac100_dma_ops = {
.init = mac100_dma_init,
.dump_regs = mac100_dump_dma_regs,
.dma_mode = mac100_dma_operation_mode,
.dma_diagnostic_fr = mac100_dma_diagnostic_fr,
};

struct stmmac_desc_ops mac100_desc_ops = {
.tx_status = mac100_get_tx_frame_status,
.rx_status = mac100_get_rx_frame_status,
.get_tx_len = mac100_get_tx_len,
.set_filter = mac100_set_filter,
.flow_ctrl = mac100_flow_ctrl,
.pmt = mac100_pmt,
.init_rx_desc = mac100_init_rx_desc,
.init_tx_desc = mac100_init_tx_desc,
.get_tx_owner = mac100_get_tx_owner,
Expand All @@ -492,9 +501,6 @@ struct stmmac_ops mac100_driver = {
.set_tx_owner = mac100_set_tx_owner,
.set_rx_owner = mac100_set_rx_owner,
.get_rx_frame_len = mac100_get_rx_frame_len,
.host_irq_status = mac100_irq_status,
.set_umac_addr = mac100_set_umac_addr,
.get_umac_addr = mac100_get_umac_addr,
};

struct mac_device_info *mac100_setup(unsigned long ioaddr)
Expand All @@ -505,13 +511,16 @@ struct mac_device_info *mac100_setup(unsigned long ioaddr)

pr_info("\tMAC 10/100\n");

mac->ops = &mac100_driver;
mac->hw.pmt = PMT_NOT_SUPPORTED;
mac->hw.link.port = MAC_CONTROL_PS;
mac->hw.link.duplex = MAC_CONTROL_F;
mac->hw.link.speed = 0;
mac->hw.mii.addr = MAC_MII_ADDR;
mac->hw.mii.data = MAC_MII_DATA;
mac->mac = &mac100_ops;
mac->desc = &mac100_desc_ops;
mac->dma = &mac100_dma_ops;

mac->pmt = PMT_NOT_SUPPORTED;
mac->link.port = MAC_CONTROL_PS;
mac->link.duplex = MAC_CONTROL_F;
mac->link.speed = 0;
mac->mii.addr = MAC_MII_ADDR;
mac->mii.data = MAC_MII_DATA;

return mac;
}
2 changes: 1 addition & 1 deletion trunk/drivers/net/stmmac/stmmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct stmmac_priv {
int rx_csum;
unsigned int dma_buf_sz;
struct device *device;
struct mac_device_info *mac_type;
struct mac_device_info *hw;

struct stmmac_extra_stats xstats;
struct napi_struct napi;
Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/net/stmmac/stmmac_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ stmmac_set_pauseparam(struct net_device *netdev,
}
} else {
unsigned long ioaddr = netdev->base_addr;
priv->mac_type->ops->flow_ctrl(ioaddr, phy->duplex,
priv->flow_ctrl, priv->pause);
priv->hw->mac->flow_ctrl(ioaddr, phy->duplex,
priv->flow_ctrl, priv->pause);
}
spin_unlock(&priv->lock);
return ret;
Expand All @@ -283,8 +283,8 @@ static void stmmac_get_ethtool_stats(struct net_device *dev,
int i;

/* Update HW stats if supported */
priv->mac_type->ops->dma_diagnostic_fr(&dev->stats, &priv->xstats,
ioaddr);
priv->hw->dma->dma_diagnostic_fr(&dev->stats, (void *) &priv->xstats,
ioaddr);

for (i = 0; i < STMMAC_STATS_LEN; i++) {
char *p = (char *)priv + stmmac_gstrings_stats[i].stat_offset;
Expand Down
Loading

0 comments on commit 2f84812

Please sign in to comment.