net: altera_tse: add write_hwaddr support
PATCH 1/1 net: altera_tse: add write_hwaddr support
Signed-off-by Thomas Chou <[email protected]>
--- drivers/net/altera_tse.c | 63 ++++++++++++++++++++++++++------------------- 1 files changed, 36 insertions(+), 27 deletions(-)
drivers/net/altera_tse.c +36 -27
@@ -752,6 +752,40 @@ static int init_phy(struct eth_device *dev)return 1 ; } +static int tse_set_mac_address (struct eth_device *dev) +{ +struct altera_tse_priv *priv = dev->priv; +volatile struct alt_tse_mac *mac_dev = priv->mac_dev; + +debug ("Setting MAC address to 0x%02x%02x%02x%02x%02x%02x\n" , + dev->enetaddr[5 ], dev->enetaddr[4 ], + dev->enetaddr[3 ], dev->enetaddr[2 ], + dev->enetaddr[1 ], dev->enetaddr[0 ]); + mac_dev->mac_addr_0 = ((dev->enetaddr[3 ]) <<24 | + (dev->enetaddr[2 ]) <<16 | + (dev->enetaddr[1 ]) <<8 | (dev->enetaddr[0 ])); + + mac_dev->mac_addr_1 = ((dev->enetaddr[5 ] <<8 | + (dev->enetaddr[4 ])) &0xFFFF ); + +/* Set the MAC address */ + mac_dev->supp_mac_addr_0_0 = mac_dev->mac_addr_0; + mac_dev->supp_mac_addr_0_1 = mac_dev->mac_addr_1; + +/* Set the MAC address */ + mac_dev->supp_mac_addr_1_0 = mac_dev->mac_addr_0; + mac_dev->supp_mac_addr_1_1 = mac_dev->mac_addr_1; + +/* Set the MAC address */ + mac_dev->supp_mac_addr_2_0 = mac_dev->mac_addr_0; + mac_dev->supp_mac_addr_2_1 = mac_dev->mac_addr_1; + +/* Set the MAC address */ + mac_dev->supp_mac_addr_3_0 = mac_dev->mac_addr_0; + mac_dev->supp_mac_addr_3_1 = mac_dev->mac_addr_1; +return 0 ; +} +static int tse_eth_init (struct eth_device *dev,bd_t * bd) {int dat;
@@ -830,33 +864,7 @@ static int tse_eth_init(struct eth_device *dev, bd_t * bd) mac_dev->command_config.image = dat;/* Set the MAC address */ -debug ("Setting MAC address to 0x%x%x%x%x%x%x\n" , - dev->enetaddr[5 ], dev->enetaddr[4 ], - dev->enetaddr[3 ], dev->enetaddr[2 ], - dev->enetaddr[1 ], dev->enetaddr[0 ]); - mac_dev->mac_addr_0 = ((dev->enetaddr[3 ]) <<24 | - (dev->enetaddr[2 ]) <<16 | - (dev->enetaddr[1 ]) <<8 | (dev->enetaddr[0 ])); - - mac_dev->mac_addr_1 = ((dev->enetaddr[5 ] <<8 | - (dev->enetaddr[4 ])) &0xFFFF ); - -/* Set the MAC address */ - mac_dev->supp_mac_addr_0_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_0_1 = mac_dev->mac_addr_1; - -/* Set the MAC address */ - mac_dev->supp_mac_addr_1_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_1_1 = mac_dev->mac_addr_1; - -/* Set the MAC address */ - mac_dev->supp_mac_addr_2_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_2_1 = mac_dev->mac_addr_1; - -/* Set the MAC address */ - mac_dev->supp_mac_addr_3_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_3_1 = mac_dev->mac_addr_1; - +tse_set_mac_address (dev);/* configure the TSE core */ /* -- output clocks, */ /* -- and later config stuff for SGMII */
@@ -920,6 +928,7 @@ int altera_tse_initialize(u8 dev_num, int mac_base, dev->halt = tse_eth_halt; dev->send = tse_eth_send; dev->recv = tse_eth_rx; + dev->write_hwaddr = tse_set_mac_address;sprintf (dev->name,"%s-%hu" ,"ALTERA_TSE" , dev_num);eth_register (dev);
Signature · 1 line
1.6.6.1
PATCH 1/1 net: altera_tse: add write_hwaddr support
Hi Thomas,
Quoted 6 lines · Thomas Chou
Signed-off-by Thomas Chou<[email protected]>--- drivers/net/altera_tse.c | 63 ++++++++++++++++++++++++++------------------- 1 files changed, 36 insertions(+), 27 deletions(-)
<snip>
Quoted 26 lines
static int tse_eth_init(struct eth_device *dev, bd_t * bd) { int dat;drivers/net/altera_tse.c +0
-19@@ -830,33 +864,7 @@ static int tse_eth_init(struct eth_device *dev, bd_t * bd) mac_dev->command_config.image = dat;/* Set the MAC address */ -debug ("Setting MAC address to 0x%x%x%x%x%x%x\n" , - dev->enetaddr[5 ], dev->enetaddr[4 ], - dev->enetaddr[3 ], dev->enetaddr[2 ], - dev->enetaddr[1 ], dev->enetaddr[0 ]); - mac_dev->mac_addr_0 = ((dev->enetaddr[3 ])<<24 | - (dev->enetaddr[2 ])<<16 | - (dev->enetaddr[1 ])<<8 | (dev->enetaddr[0 ])); - - mac_dev->mac_addr_1 = ((dev->enetaddr[5 ]<<8 | - (dev->enetaddr[4 ]))&0xFFFF ); - -/* Set the MAC address */ - mac_dev->supp_mac_addr_0_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_0_1 = mac_dev->mac_addr_1; - -/* Set the MAC address */ - mac_dev->supp_mac_addr_1_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_1_1 = mac_dev->mac_addr_1; -
drivers/net/altera_tse.c static int tse_eth_init(struct eth_device *dev, bd_t * bd) · line 868
Quoted 10 lines
drivers/net/altera_tse.c +1
-8-/* Set the MAC address */ - mac_dev->supp_mac_addr_2_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_2_1 = mac_dev->mac_addr_1; - -/* Set the MAC address */ - mac_dev->supp_mac_addr_3_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_3_1 = mac_dev->mac_addr_1; - +tse_set_mac_address (dev);
Why is this needed? Do you see a situation where the user would 'setenv ethmacskip' and then actually use the interface?
regards,
Ben
PATCH v2 1/1 net: altera_tse: add write_hwaddr support
In reply to Thomas ChouSigned-off-by Thomas Chou <[email protected]>
---
v2 remove set mac address from init.
drivers/net/altera_tse.c | 63 +++++++++++++++++++++++++-------------------- 1 files changed, 35 insertions(+), 28 deletions(-)
drivers/net/altera_tse.c +35 -28
@@ -752,6 +752,40 @@ static int init_phy(struct eth_device *dev)return 1 ; } +static int tse_set_mac_address (struct eth_device *dev) +{ +struct altera_tse_priv *priv = dev->priv; +volatile struct alt_tse_mac *mac_dev = priv->mac_dev; + +debug ("Setting MAC address to 0x%02x%02x%02x%02x%02x%02x\n" , + dev->enetaddr[5 ], dev->enetaddr[4 ], + dev->enetaddr[3 ], dev->enetaddr[2 ], + dev->enetaddr[1 ], dev->enetaddr[0 ]); + mac_dev->mac_addr_0 = ((dev->enetaddr[3 ]) <<24 | + (dev->enetaddr[2 ]) <<16 | + (dev->enetaddr[1 ]) <<8 | (dev->enetaddr[0 ])); + + mac_dev->mac_addr_1 = ((dev->enetaddr[5 ] <<8 | + (dev->enetaddr[4 ])) &0xFFFF ); + +/* Set the MAC address */ + mac_dev->supp_mac_addr_0_0 = mac_dev->mac_addr_0; + mac_dev->supp_mac_addr_0_1 = mac_dev->mac_addr_1; + +/* Set the MAC address */ + mac_dev->supp_mac_addr_1_0 = mac_dev->mac_addr_0; + mac_dev->supp_mac_addr_1_1 = mac_dev->mac_addr_1; + +/* Set the MAC address */ + mac_dev->supp_mac_addr_2_0 = mac_dev->mac_addr_0; + mac_dev->supp_mac_addr_2_1 = mac_dev->mac_addr_1; + +/* Set the MAC address */ + mac_dev->supp_mac_addr_3_0 = mac_dev->mac_addr_0; + mac_dev->supp_mac_addr_3_1 = mac_dev->mac_addr_1; +return 0 ; +} +static int tse_eth_init (struct eth_device *dev,bd_t * bd) {int dat;
@@ -829,34 +863,6 @@ static int tse_eth_init(struct eth_device *dev, bd_t * bd) mac_dev->command_config.image = dat; -/* Set the MAC address */ -debug ("Setting MAC address to 0x%x%x%x%x%x%x\n" , - dev->enetaddr[5 ], dev->enetaddr[4 ], - dev->enetaddr[3 ], dev->enetaddr[2 ], - dev->enetaddr[1 ], dev->enetaddr[0 ]); - mac_dev->mac_addr_0 = ((dev->enetaddr[3 ]) <<24 | - (dev->enetaddr[2 ]) <<16 | - (dev->enetaddr[1 ]) <<8 | (dev->enetaddr[0 ])); - - mac_dev->mac_addr_1 = ((dev->enetaddr[5 ] <<8 | - (dev->enetaddr[4 ])) &0xFFFF ); - -/* Set the MAC address */ - mac_dev->supp_mac_addr_0_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_0_1 = mac_dev->mac_addr_1; - -/* Set the MAC address */ - mac_dev->supp_mac_addr_1_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_1_1 = mac_dev->mac_addr_1; - -/* Set the MAC address */ - mac_dev->supp_mac_addr_2_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_2_1 = mac_dev->mac_addr_1; - -/* Set the MAC address */ - mac_dev->supp_mac_addr_3_0 = mac_dev->mac_addr_0; - mac_dev->supp_mac_addr_3_1 = mac_dev->mac_addr_1; -/* configure the TSE core */ /* -- output clocks, */ /* -- and later config stuff for SGMII */
@@ -920,6 +926,7 @@ int altera_tse_initialize(u8 dev_num, int mac_base, dev->halt = tse_eth_halt; dev->send = tse_eth_send; dev->recv = tse_eth_rx; + dev->write_hwaddr = tse_set_mac_address;sprintf (dev->name,"%s-%hu" ,"ALTERA_TSE" , dev_num);eth_register (dev);
Signature · 1 line
1.6.6.1
Ben Warren
AppliedPATCH v2 1/1 net: altera_tse: add write_hwaddr support
Thomas,
Quoted 7 lines · Thomas Chou
Signed-off-by Thomas Chou<[email protected]>---
v2 remove set mac address from init.drivers/net/altera_tse.c | 63 +++++++++++++++++++++++++-------------------- 1 files changed, 35 insertions(+), 28 deletions(-)
Applied to net repo.
thanks,
Ben