bnx2x: refactor nvram related code and update version
v4 cover bnx2x: refactor nvram related code and update version
Hi Dave,
Please cosider appliyng the series to net-next.
Changes for v2->v3:
1/4 * was separated into 3 patches [1-3/6] pointed out by Francois Romieu
* some cosmetics and beautifications was applied.
* bnx2x_nvram_read32 rearranged according to Francois Romieu's comments
2/4 * move to be 4/6
* some code were extracted into fuctions in order to stop processing once error was detected.
* removed inaccurate decoding of errors - left only error messages according to Francois Romieu's comments
* removed useless init according to Francois Romieu's comment
Changes for v3->v4
4/6 * removed some emtry lines
* fixed lines over 80 chars
Thanks
Dmitry
PATCH v4 1/6 bnx2x: refactor nvram read procedure
introduce a procedure to read in u32 granularity.
--- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +21 -7
@@ -1364,6 +1364,23 @@ static int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf,return rc; } +static int bnx2x_nvram_read32 (struct bnx2x *bp,u32 offset,u32 *buf, +int buf_size) +{ +int rc; + + rc =bnx2x_nvram_read (bp, offset, (u8 *)buf, buf_size); + +if (!rc) { +__be32 *be = (__be32 *)buf; + +while ((buf_size -=4 ) >=0 ) + *buf++ =be32_to_cpu (*be++); + } + +return rc; +} +static int bnx2x_get_eeprom (struct net_device *dev,struct ethtool_eeprom *eeprom,u8 *eebuf) {
@@ -2598,8 +2615,7 @@ static int bnx2x_test_nvram(struct bnx2x *bp) { 0x708, 0x70 }, /* manuf_key_info */ { 0, 0 } }; -__be32 *buf; -u8 *data; +u8 *buf;int i, rc;u32 magic, crc;
@@ -2612,16 +2628,14 @@ static int bnx2x_test_nvram(struct bnx2x *bp) rc = -ENOMEM ; goto test_nvram_exit; } - data = (u8 *)buf; - rc =bnx2x_nvram_read (bp,0 , data,4 ); + rc =bnx2x_nvram_read32 (bp,0 , &magic,sizeof (magic));if (rc) {DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM ,"magic value read (rc %d)\n" , rc); goto test_nvram_exit; } - magic =be32_to_cpu (buf[0 ]);if (magic !=0x669955aa ) {DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM ,"wrong magic value (0x%08x)\n" , magic);
@@ -2631,7 +2645,7 @@ static int bnx2x_test_nvram(struct bnx2x *bp)for (i =0 ; nvram_tbl[i].size; i++) { - rc =bnx2x_nvram_read (bp, nvram_tbl[i].offset, data, + rc =bnx2x_nvram_read (bp, nvram_tbl[i].offset, buf, nvram_tbl[i].size);if (rc) { DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
@@ -2639,7 +2653,7 @@ static int bnx2x_test_nvram(struct bnx2x *bp) goto test_nvram_exit; } - crc =ether_crc_le (nvram_tbl[i].size, data); + crc =ether_crc_le (nvram_tbl[i].size, buf);if (crc !=CRC32_RESIDUAL ) {DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM ,"nvram_tbl[%d] wrong crc value (0x%08x)\n" , i, crc);
Signature · 1 line
1.8.1.4
PATCH v4 2/6 bnx2x: fix byte-by-byte nvram write for BE machines
In reply to Dmitry Kravkov--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +7 -8
@@ -1569,9 +1569,8 @@ static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf, int buf_size) {int rc; -u32 cmd_flags; -u32 align_offset; -__be32 val; +u32 cmd_flags, align_offset, val; +__be32 val_be;if (offset + buf_size > bp->common.flash_size) { DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
@@ -1590,16 +1589,16 @@ static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf, cmd_flags = (MCPR_NVM_COMMAND_FIRST |MCPR_NVM_COMMAND_LAST ); align_offset = (offset & ~0x03 ); - rc =bnx2x_nvram_read_dword (bp, align_offset, &val, cmd_flags); + rc =bnx2x_nvram_read_dword (bp, align_offset, &val_be, cmd_flags);if (rc ==0 ) { - val &= ~(0xff <<BYTE_OFFSET (offset)); - val |= (*data_buf <<BYTE_OFFSET (offset)); -/* nvram data is returned as an array of bytes * convert it back to cpu order */ - val =be32_to_cpu (val); + val =be32_to_cpu (val_be); + + val &= ~le32_to_cpu (0xff <<BYTE_OFFSET (offset)); + val |=le32_to_cpu (*data_buf <<BYTE_OFFSET (offset)); rc =bnx2x_nvram_write_dword (bp, align_offset, val, cmd_flags);
Signature · 1 line
1.8.1.4
PATCH v4 3/6 bnx2x: remove non-necessary assignment
In reply to Dmitry Kravkov--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +1 -4
@@ -1385,7 +1385,6 @@ static int bnx2x_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *eebuf) { struct bnx2x *bp = netdev_priv(dev); -int rc;if (!netif_running (dev)) { DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
@@ -1400,9 +1399,7 @@ static int bnx2x_get_eeprom(struct net_device *dev,/* parameters already validated in ethtool_get_eeprom */ - rc =bnx2x_nvram_read (bp, eeprom->offset, eebuf, eeprom->len); - -return rc; +return bnx2x_nvram_read (bp, eeprom->offset, eebuf, eeprom->len); } static int bnx2x_get_module_eeprom(struct net_device *dev,
Signature · 1 line
1.8.1.4
PATCH v4 4/6 bnx2x: add additional regions for CRC memory test
In reply to Dmitry Kravkova. Common tree of dir structures.
b. Multi-port devices structures.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 7 +- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 201 +++++++++++++++++++-- 2 files changed, 185 insertions(+), 23 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +4 -3
@@ -850,6 +850,9 @@ struct bnx2x_common {#define CHIP_IS_57840_VF (bp) (CHIP_NUM(bp) == CHIP_NUM_57840_VF)#define CHIP_IS_E1H (bp) (CHIP_IS_57711(bp) || \ CHIP_IS_57711E(bp)) +#define CHIP_IS_57811xx (bp) (CHIP_IS_57811(bp) || \ + CHIP_IS_57811_MF(bp) || \ + CHIP_IS_57811_VF(bp))#define CHIP_IS_E2 (bp) (CHIP_IS_57712(bp) || \ CHIP_IS_57712_MF(bp) || \ CHIP_IS_57712_VF(bp))
@@ -859,9 +862,7 @@ struct bnx2x_common {CHIP_IS_57810 (bp) || \CHIP_IS_57810_MF (bp) || \CHIP_IS_57810_VF (bp) || \ -CHIP_IS_57811 (bp) || \ -CHIP_IS_57811_MF (bp) || \ -CHIP_IS_57811_VF (bp) || \ +CHIP_IS_57811xx (bp) || \CHIP_IS_57840 (bp) || \CHIP_IS_57840_MF (bp) || \ CHIP_IS_57840_VF(bp))
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +181 -20
234 lines not on this page · raw message
Signature · 1 line
1.8.1.4
PATCH v4 5/6 bnx2x: allow nvram test to run when device is down
In reply to Dmitry Kravkov--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +10 -9
@@ -2864,9 +2864,16 @@ static void bnx2x_self_test(struct net_device *dev,memset (buf,0 ,sizeof (u64) *BNX2X_NUM_TESTS (bp)); +if (bnx2x_test_nvram (bp) !=0 ) { +if (!IS_MF (bp)) + buf[4 ] =1 ; +else + buf[0 ] =1 ; + etest->flags |=ETH_TEST_FL_FAILED ; + } +if (!netif_running (dev)) { -DP (BNX2X_MSG_ETHTOOL , -"Can't perform self-test when interface is down\n" ); +DP (BNX2X_MSG_ETHTOOL ,"Interface is down\n" );return ; }
@@ -2928,13 +2935,7 @@ static void bnx2x_self_test(struct net_device *dev,/* wait until link state is restored */ bnx2x_wait_for_link (bp, link_up, is_serdes); } -if (bnx2x_test_nvram (bp) !=0 ) { -if (!IS_MF (bp)) - buf[4 ] =1 ; -else - buf[0 ] =1 ; - etest->flags |=ETH_TEST_FL_FAILED ; - } +if (bnx2x_test_intr (bp) !=0 ) {if (!IS_MF (bp)) buf[5 ] =1 ;
Signature · 1 line
1.8.1.4
PATCH v4 6/6 bnx2x: update version to 1.78.17-0
In reply to Dmitry Kravkov--- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +2 -2
@@ -26,8 +26,8 @@* (you will need to reboot afterwards) */ /* #define BNX2X_STOP_ON_ERROR */ -#define DRV_MODULE_VERSION "1.78.02-0" -#define DRV_MODULE_RELDATE "2013/01/14" +#define DRV_MODULE_VERSION "1.78.17-0" +#define DRV_MODULE_RELDATE "2013/04/11"#define BNX2X_BC_VER 0x040200#if defined(CONFIG_DCB )
Signature · 1 line
1.8.1.4
David Miller
maintainerFrom: "Dmitry Kravkov" <[email protected]>
Date: Mon, 22 Apr 2013 16:48:05 +0300
Quoted 1 line
Please cosider appliyng the series to net-next.
All applied.