bnx2x: refactor nvram related code and update version
v2 cover bnx2x: refactor nvram related code and update version
Hi Dave,
Please cosider appliyng the series to net-next.
Changes for v2:
* 1/4: remove boolean parameter and introduce bnx2x_nvram_read32
* pointed out by Francois Romieu <[email protected]>
* 2/4: adopt to changes in [1/4]
Thanks
Dmitry
PATCH v2 1/4 bnx2x: refactor nvram read procedure
introduce a procedure to read in u32 granularity.
--- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 54 +++++++++++++--------- 1 file changed, 31 insertions(+), 23 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +31 -23
@@ -1364,11 +1364,25 @@ 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 i, rc =bnx2x_nvram_read (bp, offset, (u8 *)buf, buf_size); +__be32 *be = (__be32 *)buf; + +if (rc) +return rc; + +for (i =0 ; i < buf_size; i +=4 ) + *buf++ =be32_to_cpu (*be++); + +return 0 ; +} +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,
@@ -1383,9 +1397,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,
@@ -1552,9 +1564,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,
@@ -1573,16 +1584,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_be); -/* nvram data is returned as an array of bytes -* convert it back to cpu order -*/ - val =be32_to_cpu (val); +if (rc ==0 ) { + 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);
@@ -2598,8 +2609,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,26 +2622,24 @@ 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); - rc = -ENODEV ; + rc = -EINVAL ; goto test_nvram_exit; }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 +2647,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
Re: [PATCH v2 net-next 1/4] bnx2x: refactor nvram read procedure
Dmitry Kravkov <[email protected]> :
Quoted 15 lines
introduce a procedure to read in u32 granularity.
CC Francois Romieu <[email protected]>Signed-off-by Dmitry Kravkov <[email protected]>Signed-off-by Eilon Greenstein <[email protected]>--- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 54 +++++++++++++--------- 1 file changed, 31 insertions(+), 23 deletions(-)drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +0
-0@@ -1364,11 +1364,25 @@ static int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf,return rc;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf, · line 1374
Quoted 10 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +8
-0} +static int bnx2x_nvram_read32 (struct bnx2x *bp,u32 offset,u32 *buf, +int buf_size) +{ +int i, rc =bnx2x_nvram_read (bp, offset, (u8 *)buf, buf_size); +__be32 *be = (__be32 *)buf; + +if (rc) +return rc;
Nit: one of those may be a tad more idiomatic. Not sure.
__be32 *be = (__be32 *)buf;
int i, rc;
rc = bnx2x_nvram_read(bp, offset, (u8 *)buf, buf_size);
if (rc)
...
or:
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++);
}[...]
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_get_eeprom(struct net_device *dev, · line 1401
Quoted 9 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +1
-3@@ -1383,9 +1397,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); }
Nit--: it's a bit off-topic.
[...]
Quoted 4 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +0
-0@@ -1573,16 +1584,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 );
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf, · line 1592
Quoted 10 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +5
-4- 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_be);
(1)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf, · line 1596
Quoted 8 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +3
-4-/* nvram data is returned as an array of bytes -* convert it back to cpu order -*/ - val =be32_to_cpu (val); +if (rc ==0 ) { + val &= ~le32_to_cpu (0xff <<BYTE_OFFSET (offset)); + val |=le32_to_cpu (*data_buf <<BYTE_OFFSET (offset));
(2)
Either be32_to_cpu or le32_to_cpu above isn't a nop but the commit message only talks of refactoring. It imho lacks a statement about a fix.
Signature · 1 line
Ueimor
RE: [PATCH v2 net-next 1/4] bnx2x: refactor nvram read procedure
Quoted 36 lines
-----Original Message-----
From: Francois Romieu [mailto:[email protected]]
Sent: Friday, April 19, 2013 2:15 AM
To: Dmitry Kravkov
Cc: [email protected]; [email protected]; Eilon Greenstein
Subject: Re: [PATCH v2 net-next 1/4] bnx2x: refactor nvram read procedureDmitry Kravkov <[email protected]> :
Quoted 15 lines
introduce a procedure to read in u32 granularity.
CC Francois Romieu <[email protected]>Signed-off-by Dmitry Kravkov <[email protected]>Signed-off-by Eilon Greenstein <[email protected]>--- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 54 +++++++++++++--------- 1 file changed, 31 insertions(+), 23 deletions(-)drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +0
-0@@ -1364,11 +1364,25 @@ static int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf,return rc;drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf, · line 1374
Quoted 10 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +8
-0} +static int bnx2x_nvram_read32 (struct bnx2x *bp,u32 offset,u32 *buf, +int buf_size) +{ +int i, rc =bnx2x_nvram_read (bp, offset, (u8 *)buf, buf_size); +__be32 *be = (__be32 *)buf; + +if (rc) +return rc;Nit: one of those may be a tad more idiomatic. Not sure.
Quoted 16 lines
__be32 *be = (__be32 *)buf;
int i, rc;
rc = bnx2x_nvram_read(bp, offset, (u8 *)buf, buf_size);
if (rc)
...
or:
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++);
}I will adopt this one :)
Quoted 5 lines
[...]
Quoted 4 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +0
-0@@ -1383,9 +1397,7 @@ static int bnx2x_get_eeprom(struct net_device *dev,/* parameters already validated in ethtool_get_eeprom */
Quoted 7 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_get_eeprom(struct net_device *dev, · line 1401
Quoted 5 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +1
-3- rc =bnx2x_nvram_read (bp, eeprom->offset, eebuf, eeprom->len); - -return rc; +return bnx2x_nvram_read (bp, eeprom->offset, eebuf, eeprom->len); }Nit--: it's a bit off-topic.
Will separate it
Quoted 29 lines
[...]
Quoted 4 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +0
-0@@ -1573,16 +1584,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 );drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf, · line 1592
Quoted 10 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +5
-4- 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_be);(1)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf, · line 1596
Quoted 8 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +3
-4-/* nvram data is returned as an array of bytes -* convert it back to cpu order -*/ - val =be32_to_cpu (val); +if (rc ==0 ) { + val &= ~le32_to_cpu (0xff <<BYTE_OFFSET (offset)); + val |=le32_to_cpu (*data_buf <<BYTE_OFFSET (offset));(2)
Quoted 3 lines
Either
be32_to_cpuorle32_to_cpuabove isn't a nop but the commit message only talks of refactoring. It imho lacks a statement about a fix.
Good catch - this one should go to -net,
I will leave it in net-next series as separate patch with proper message to avoid painful merging, if Dave does not objection for this.
Quoted 2 lines
--
Ueimor
PATCH v2 2/4 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 | 171 ++++++++++++++++++--- 2 files changed, 155 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 +151 -20
204 lines not on this page · raw message
Signature · 1 line
1.8.1.4
Re: [PATCH v2 net-next 2/4] bnx2x: add additional regions for CRC memory test
Dmitry Kravkov <[email protected]> :
[...]
Quoted 19 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +11
-0@@ -2593,14 +2593,138 @@ static int bnx2x_test_ext_loopback(struct bnx2x *bp)return rc; } +struct code_entry { +u32 sram_start_addr; +u32 code_attribute; +#define CODE_IMAGE_TYPE_MASK 0xf0800003 +#define CODE_IMAGE_VNTAG_PROFILES_DATA 0xd0000003 +#define CODE_IMAGE_LENGTH_MASK 0x007ffffc +#define CODE_IMAGE_TYPE_EXTENDED_DIR 0xe0000000 +u32 nvm_start_addr; +}; + +#define CODE_ENTRY_MAX 16
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_test_ext_loopback(struct bnx2x *bp) · line 2616
Quoted 10 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +9
-0+#define CODE_ENTRY_EXTENDED_DIR_IDX 15 +#define MAX_IMAGES_IN_EXTENDED_DIR 64 +#define CRC32_RESIDUAL 0xdebb20e3 +#define CRC_BUFF_SIZE 256 + +static int bnx2x_nvram_crc (struct bnx2x *bp, +int offset, +int size, +u8 *buff)
static int bnx2x_nvram_crc(struct bnx2x *bp, int offset, int size, u8 *buff)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_test_ext_loopback(struct bnx2x *bp) · line 2628
Quoted 12 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +12
-0+{ +u32 crc = ~0 ; +int done =0 ; + +DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM , +"NVRAM CRC from 0x%08x to 0x%08x\n" , offset, offset + size); + +while (done < size) { +int count =min_t (int, size - done,CRC_BUFF_SIZE ); + +if (bnx2x_nvram_read (bp, offset + done, buff, count)) +return -EIO ;
You may propagate the status code from bnx2x_nvram_read.
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_test_ext_loopback(struct bnx2x *bp) · line 2636
Quoted 8 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +8
-0+ crc =crc32_le (crc, buff, count); + done += count; + } + +if (crc !=CRC32_RESIDUAL ) +return -EINVAL ; + +return 0 ;
A ternary operator could be used. Your choice of style.
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_test_ext_loopback(struct bnx2x *bp) · line 2645
Quoted 9 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +9
-0+} + +static int bnx2x_test_nvram_dir (struct bnx2x *bp, +struct code_entry *entry, +u8 *buff) +{ +size_t size = entry->code_attribute &CODE_IMAGE_LENGTH_MASK ; +u32 type = entry->code_attribute &CODE_IMAGE_TYPE_MASK ; +int rc =0 ;
Useless init.
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_test_ext_loopback(struct bnx2x *bp) · line 2657
Quoted 12 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +12
-0+ +/* Zero-length images and AFEX profiles do not have CRC */ +if (size ==0 || type ==CODE_IMAGE_VNTAG_PROFILES_DATA ) +return 0 ; + + rc =bnx2x_nvram_crc (bp, entry->nvm_start_addr, size, buff); +if (rc == -EIO ) +DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM , +"Unable to read image %x\n" , type); +else if (rc) +DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM , +"image %x has wrong crc value\n" , type);
It's a bit ugly.
bnx2x_nvram_crc perfectly knowns if a read failure or a crc problem happened. It can print messages and you won't need to analyze the failure status. You may still print some different message in its callers (here and bnx2x_test_nvram_tbl).
I must stop here, sorry.
Signature · 1 line
Ueimor
RE: [PATCH v2 net-next 2/4] bnx2x: add additional regions for CRC memory test
Quoted 67 lines
-----Original Message-----
From: Francois Romieu [mailto:[email protected]]
Sent: Friday, April 19, 2013 2:15 AM
To: Dmitry Kravkov
Cc: [email protected]; [email protected]; Eilon Greenstein
Subject: Re: [PATCH v2 net-next 2/4] bnx2x: add additional regions for CRC memory testDmitry Kravkov <[email protected]> :
[...]Quoted 19 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +11
-0@@ -2593,14 +2593,138 @@ static int bnx2x_test_ext_loopback(struct bnx2x *bp)return rc; } +struct code_entry { +u32 sram_start_addr; +u32 code_attribute; +#define CODE_IMAGE_TYPE_MASK 0xf0800003 +#define CODE_IMAGE_VNTAG_PROFILES_DATA 0xd0000003 +#define CODE_IMAGE_LENGTH_MASK 0x007ffffc +#define CODE_IMAGE_TYPE_EXTENDED_DIR 0xe0000000 +u32 nvm_start_addr; +}; + +#define CODE_ENTRY_MAX 16drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_test_ext_loopback(struct bnx2x *bp) · line 2616
Quoted 10 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +9
-0+#define CODE_ENTRY_EXTENDED_DIR_IDX 15 +#define MAX_IMAGES_IN_EXTENDED_DIR 64 +#define CRC32_RESIDUAL 0xdebb20e3 +#define CRC_BUFF_SIZE 256 + +static int bnx2x_nvram_crc (struct bnx2x *bp, +int offset, +int size, +u8 *buff)static int
bnx2x_nvram_crc(struct bnx2x *bp, int offset, int size, u8 *buff)drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_test_ext_loopback(struct bnx2x *bp) · line 2628
Quoted 12 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +12
-0+{ +u32 crc = ~0 ; +int done =0 ; + +DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM , +"NVRAM CRC from 0x%08x to 0x%08x\n" , offset, offset + size); + +while (done < size) { +int count =min_t (int, size - done,CRC_BUFF_SIZE ); + +if (bnx2x_nvram_read (bp, offset + done, buff, count)) +return -EIO ;You may propagate the status code from
bnx2x_nvram_read.drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_test_ext_loopback(struct bnx2x *bp) · line 2636
Quoted 8 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +8
-0+ crc =crc32_le (crc, buff, count); + done += count; + } + +if (crc !=CRC32_RESIDUAL ) +return -EINVAL ; + +return 0 ;A ternary operator could be used. Your choice of style.
Quoted 11 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_test_ext_loopback(struct bnx2x *bp) · line 2645
Quoted 9 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +9
-0+} + +static int bnx2x_test_nvram_dir (struct bnx2x *bp, +struct code_entry *entry, +u8 *buff) +{ +size_t size = entry->code_attribute &CODE_IMAGE_LENGTH_MASK ; +u32 type = entry->code_attribute &CODE_IMAGE_TYPE_MASK ; +int rc =0 ;Useless init.
To be fixed
Quoted 15 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c static int bnx2x_test_ext_loopback(struct bnx2x *bp) · line 2657
Quoted 12 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +12
-0+ +/* Zero-length images and AFEX profiles do not have CRC */ +if (size ==0 || type ==CODE_IMAGE_VNTAG_PROFILES_DATA ) +return 0 ; + + rc =bnx2x_nvram_crc (bp, entry->nvm_start_addr, size, buff); +if (rc == -EIO ) +DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM , +"Unable to read image %x\n" , type); +else if (rc) +DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM , +"image %x has wrong crc value\n" , type);It's a bit ugly.
Quoted 4 lines
bnx2x_nvram_crcperfectly knowns if a read failure or a crc problem happened. It can print messages and you won't need to analyze the failure status. You may still print some different message in its callers (here andbnx2x_test_nvram_tbl).
I will fix to common mesaage for type only
Quoted 2 lines
I must stop here, sorry.
Thank you!!
Quoted 2 lines
--
Ueimor
PATCH v2 3/4 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
@@ -2832,9 +2832,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 ; }
@@ -2896,13 +2903,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 v2 4/4 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