* [net-next-2.6 24/27] e1000e: minor error message corrections
@ 2010-12-10 10:06 Jeff Kirsher
2010-12-10 10:06 ` [net-next-2.6 25/27] e1000e: static analysis tools complain of a possible null ptr p dereference Jeff Kirsher
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Jeff Kirsher @ 2010-12-10 10:06 UTC (permalink / raw)
To: davem, davem; +Cc: Bruce Allan, netdev, gospo, bphilips, Jeff Kirsher
From: Bruce Allan <bruce.w.allan@intel.com>
Correct error messages when setting up Rx resources and when checking
module parameters.
Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Tested-by: Jeff Pieper <jeffrey.e.pieper@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/e1000e/netdev.c | 2 +-
drivers/net/e1000e/param.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 4bf843a..6e1f3a3 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2130,7 +2130,7 @@ err_pages:
}
err:
vfree(rx_ring->buffer_info);
- e_err("Unable to allocate memory for the transmit descriptor ring\n");
+ e_err("Unable to allocate memory for the receive descriptor ring\n");
return err;
}
diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c
index 3d36911..a9612b0 100644
--- a/drivers/net/e1000e/param.c
+++ b/drivers/net/e1000e/param.c
@@ -421,7 +421,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
static const struct e1000_option opt = {
.type = enable_option,
.name = "CRC Stripping",
- .err = "defaulting to enabled",
+ .err = "defaulting to Enabled",
.def = OPTION_ENABLED
};
--
1.7.3.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [net-next-2.6 25/27] e1000e: static analysis tools complain of a possible null ptr p dereference 2010-12-10 10:06 [net-next-2.6 24/27] e1000e: minor error message corrections Jeff Kirsher @ 2010-12-10 10:06 ` Jeff Kirsher 2010-12-10 12:44 ` Joe Perches 2010-12-10 10:06 ` [net-next-2.6 26/27] e1000e: increment the driver version Jeff Kirsher 2010-12-10 10:06 ` [net-next-2.6 27/27] igb: Add new function to read part number from EEPROM in string format Jeff Kirsher 2 siblings, 1 reply; 8+ messages in thread From: Jeff Kirsher @ 2010-12-10 10:06 UTC (permalink / raw) To: davem, davem; +Cc: Bruce Allan, netdev, gospo, bphilips, Jeff Kirsher From: Bruce Allan <bruce.w.allan@intel.com> Adding this default case resolves the issue. Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Tested-by: Emil Tantilov <emil.s.tantilov@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> --- drivers/net/e1000e/ethtool.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c index 29b09113..72ce0ec 100644 --- a/drivers/net/e1000e/ethtool.c +++ b/drivers/net/e1000e/ethtool.c @@ -1992,6 +1992,10 @@ static void e1000_get_ethtool_stats(struct net_device *netdev, p = (char *) adapter + e1000_gstrings_stats[i].stat_offset; break; + default: + data[i] = 0; + continue; + break; } data[i] = (e1000_gstrings_stats[i].sizeof_stat == -- 1.7.3.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [net-next-2.6 25/27] e1000e: static analysis tools complain of a possible null ptr p dereference 2010-12-10 10:06 ` [net-next-2.6 25/27] e1000e: static analysis tools complain of a possible null ptr p dereference Jeff Kirsher @ 2010-12-10 12:44 ` Joe Perches 2010-12-10 19:35 ` Tantilov, Emil S 0 siblings, 1 reply; 8+ messages in thread From: Joe Perches @ 2010-12-10 12:44 UTC (permalink / raw) To: Jeff Kirsher; +Cc: davem, davem, Bruce Allan, netdev, gospo, bphilips On Fri, 2010-12-10 at 02:06 -0800, Jeff Kirsher wrote: > diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c [] > + default: > + data[i] = 0; > + continue; > + break; Using continue; break; is odd and unhelpful. Just continue; is sufficient and clear. ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [net-next-2.6 25/27] e1000e: static analysis tools complain of a possible null ptr p dereference 2010-12-10 12:44 ` Joe Perches @ 2010-12-10 19:35 ` Tantilov, Emil S 2010-12-10 19:58 ` Joe Perches 2010-12-10 20:16 ` David Miller 0 siblings, 2 replies; 8+ messages in thread From: Tantilov, Emil S @ 2010-12-10 19:35 UTC (permalink / raw) To: Joe Perches, Kirsher, Jeffrey T Cc: davem@davemloft.net, davem@davemleft.org, Allan, Bruce W, netdev@vger.kernel.org, gospo@redhat.com, bphilips@novell.com >-----Original Message----- >From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org] On >Behalf Of Joe Perches >Sent: Friday, December 10, 2010 4:45 AM >To: Kirsher, Jeffrey T >Cc: davem@davemloft.net; davem@davemleft.org; Allan, Bruce W; >netdev@vger.kernel.org; gospo@redhat.com; bphilips@novell.com >Subject: Re: [net-next-2.6 25/27] e1000e: static analysis tools complain of >a possible null ptr p dereference > >On Fri, 2010-12-10 at 02:06 -0800, Jeff Kirsher wrote: >> diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c >[] >> + default: >> + data[i] = 0; >> + continue; >> + break; > >Using > > continue; > break; > >is odd and unhelpful. >Just continue; is sufficient and clear. It's odd and without consequence but not necessarily "unhelpful" as it can protect from bugs in case someone was to add another case statement. While unlikely, bugs in switch statements due to missing breaks are not unheard of. Looking at the kernel source there is no consistency as far as break in the default: case is concerned. Dave, unless this is infringing on some coding style rule, I would request that the patch be applied as is. Thanks, Emil ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [net-next-2.6 25/27] e1000e: static analysis tools complain of a possible null ptr p dereference 2010-12-10 19:35 ` Tantilov, Emil S @ 2010-12-10 19:58 ` Joe Perches 2010-12-10 20:16 ` David Miller 1 sibling, 0 replies; 8+ messages in thread From: Joe Perches @ 2010-12-10 19:58 UTC (permalink / raw) To: Tantilov, Emil S Cc: Kirsher, Jeffrey T, davem@davemloft.net, Allan, Bruce W, netdev@vger.kernel.org, gospo@redhat.com, bphilips@novell.com, netdev@vger.kernel.org, gospo@redhat.com, bphilips@novell.com On Fri, 2010-12-10 at 12:35 -0700, Tantilov, Emil S wrote: > >On Fri, 2010-12-10 at 02:06 -0800, Jeff Kirsher wrote: > >> diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c > >[] > >> + default: > >> + data[i] = 0; > >> + continue; > >> + break; > >Using > > continue; > > break; > >is odd and unhelpful. > >Just continue; is sufficient and clear. > It's odd and without consequence but not necessarily "unhelpful" as it > can protect from bugs in case someone was to add another case > statement. continue statements are not fall-through. Adding another case statement in the switch below this case label would work just fine. > While unlikely, bugs in switch statements due to missing breaks are > not unheard of. True, but that's not this case. > Looking at the kernel source there is no consistency as far as break > in the default: case is concerned. It's not the break, it's the break after continue that's odd. Glancing through the source code using $ grep -rP --include=*.[ch] -B 3 "\bcontinue\s*;\s*break\s*;" * this is a pretty unusual coding style. Most all of the matches are like: if (condition) continue; break; Your choice, your code. I just think it's ugly as well as odd and unhelpful. cheers, Joe ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [net-next-2.6 25/27] e1000e: static analysis tools complain of a possible null ptr p dereference 2010-12-10 19:35 ` Tantilov, Emil S 2010-12-10 19:58 ` Joe Perches @ 2010-12-10 20:16 ` David Miller 1 sibling, 0 replies; 8+ messages in thread From: David Miller @ 2010-12-10 20:16 UTC (permalink / raw) To: emil.s.tantilov Cc: joe, jeffrey.t.kirsher, davem, bruce.w.allan, netdev, gospo, bphilips From: "Tantilov, Emil S" <emil.s.tantilov@intel.com> Date: Fri, 10 Dec 2010 12:35:45 -0700 > Dave, unless this is infringing on some coding style rule, I would request that the patch be applied as is. I think Ben's request is more than reasonable. Please make his requested change. "continue; break;" looks quite silly to me too. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [net-next-2.6 26/27] e1000e: increment the driver version 2010-12-10 10:06 [net-next-2.6 24/27] e1000e: minor error message corrections Jeff Kirsher 2010-12-10 10:06 ` [net-next-2.6 25/27] e1000e: static analysis tools complain of a possible null ptr p dereference Jeff Kirsher @ 2010-12-10 10:06 ` Jeff Kirsher 2010-12-10 10:06 ` [net-next-2.6 27/27] igb: Add new function to read part number from EEPROM in string format Jeff Kirsher 2 siblings, 0 replies; 8+ messages in thread From: Jeff Kirsher @ 2010-12-10 10:06 UTC (permalink / raw) To: davem, davem; +Cc: Bruce Allan, netdev, gospo, bphilips, Jeff Kirsher From: Bruce Allan <bruce.w.allan@intel.com> Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Tested-by: Jeff Pieper <jeffrey.e.pieper@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> --- drivers/net/e1000e/netdev.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index 6e1f3a3..5530d0b 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c @@ -54,7 +54,7 @@ #define DRV_EXTRAVERSION "-k2" -#define DRV_VERSION "1.2.7" DRV_EXTRAVERSION +#define DRV_VERSION "1.2.20" DRV_EXTRAVERSION char e1000e_driver_name[] = "e1000e"; const char e1000e_driver_version[] = DRV_VERSION; -- 1.7.3.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [net-next-2.6 27/27] igb: Add new function to read part number from EEPROM in string format 2010-12-10 10:06 [net-next-2.6 24/27] e1000e: minor error message corrections Jeff Kirsher 2010-12-10 10:06 ` [net-next-2.6 25/27] e1000e: static analysis tools complain of a possible null ptr p dereference Jeff Kirsher 2010-12-10 10:06 ` [net-next-2.6 26/27] e1000e: increment the driver version Jeff Kirsher @ 2010-12-10 10:06 ` Jeff Kirsher 2 siblings, 0 replies; 8+ messages in thread From: Jeff Kirsher @ 2010-12-10 10:06 UTC (permalink / raw) To: davem, davem; +Cc: Carolyn Wyborny, netdev, gospo, bphilips, Jeff Kirsher From: Carolyn Wyborny <carolyn.wyborny@intel.com> New adapters will have part numbers stored in string format rather than simple hex format. This function will read part number formats in either hex or string. Signed-off-by: Carolyn Wyborny <carolyn.wyborny@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> --- drivers/net/igb/e1000_defines.h | 7 +++ drivers/net/igb/e1000_nvm.c | 93 ++++++++++++++++++++++++++++++++++++--- drivers/net/igb/e1000_nvm.h | 2 + drivers/net/igb/igb_main.c | 11 +++-- 4 files changed, 102 insertions(+), 11 deletions(-) diff --git a/drivers/net/igb/e1000_defines.h b/drivers/net/igb/e1000_defines.h index 6222279..6319ed9 100644 --- a/drivers/net/igb/e1000_defines.h +++ b/drivers/net/igb/e1000_defines.h @@ -419,6 +419,9 @@ #define E1000_ERR_SWFW_SYNC 13 #define E1000_NOT_IMPLEMENTED 14 #define E1000_ERR_MBX 15 +#define E1000_ERR_INVALID_ARGUMENT 16 +#define E1000_ERR_NO_SPACE 17 +#define E1000_ERR_NVM_PBA_SECTION 18 /* Loop limit on how long we wait for auto-negotiation to complete */ #define COPPER_LINK_UP_LIMIT 10 @@ -580,11 +583,15 @@ /* Mask bits for fields in Word 0x1a of the NVM */ +/* length of string needed to store part num */ +#define E1000_PBANUM_LENGTH 11 + /* For checksumming, the sum of all words in the NVM should equal 0xBABA. */ #define NVM_SUM 0xBABA #define NVM_PBA_OFFSET_0 8 #define NVM_PBA_OFFSET_1 9 +#define NVM_PBA_PTR_GUARD 0xFAFA #define NVM_WORD_SIZE_BASE_SHIFT 6 /* NVM Commands - Microwire */ diff --git a/drivers/net/igb/e1000_nvm.c b/drivers/net/igb/e1000_nvm.c index d83b77fa..6b5cc2c 100644 --- a/drivers/net/igb/e1000_nvm.c +++ b/drivers/net/igb/e1000_nvm.c @@ -445,31 +445,112 @@ out: } /** - * igb_read_part_num - Read device part number + * igb_read_part_string - Read device part number * @hw: pointer to the HW structure * @part_num: pointer to device part number + * @part_num_size: size of part number buffer * * Reads the product board assembly (PBA) number from the EEPROM and stores * the value in part_num. **/ -s32 igb_read_part_num(struct e1000_hw *hw, u32 *part_num) +s32 igb_read_part_string(struct e1000_hw *hw, u8 *part_num, u32 part_num_size) { - s32 ret_val; + s32 ret_val; u16 nvm_data; + u16 pointer; + u16 offset; + u16 length; + + if (part_num == NULL) { + hw_dbg("PBA string buffer was null\n"); + ret_val = E1000_ERR_INVALID_ARGUMENT; + goto out; + } ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_0, 1, &nvm_data); if (ret_val) { hw_dbg("NVM Read Error\n"); goto out; } - *part_num = (u32)(nvm_data << 16); - ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_1, 1, &nvm_data); + ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_1, 1, &pointer); + if (ret_val) { + hw_dbg("NVM Read Error\n"); + goto out; + } + + /* + * if nvm_data is not ptr guard the PBA must be in legacy format which + * means pointer is actually our second data word for the PBA number + * and we can decode it into an ascii string + */ + if (nvm_data != NVM_PBA_PTR_GUARD) { + hw_dbg("NVM PBA number is not stored as string\n"); + + /* we will need 11 characters to store the PBA */ + if (part_num_size < 11) { + hw_dbg("PBA string buffer too small\n"); + return E1000_ERR_NO_SPACE; + } + + /* extract hex string from data and pointer */ + part_num[0] = (nvm_data >> 12) & 0xF; + part_num[1] = (nvm_data >> 8) & 0xF; + part_num[2] = (nvm_data >> 4) & 0xF; + part_num[3] = nvm_data & 0xF; + part_num[4] = (pointer >> 12) & 0xF; + part_num[5] = (pointer >> 8) & 0xF; + part_num[6] = '-'; + part_num[7] = 0; + part_num[8] = (pointer >> 4) & 0xF; + part_num[9] = pointer & 0xF; + + /* put a null character on the end of our string */ + part_num[10] = '\0'; + + /* switch all the data but the '-' to hex char */ + for (offset = 0; offset < 10; offset++) { + if (part_num[offset] < 0xA) + part_num[offset] += '0'; + else if (part_num[offset] < 0x10) + part_num[offset] += 'A' - 0xA; + } + + goto out; + } + + ret_val = hw->nvm.ops.read(hw, pointer, 1, &length); if (ret_val) { hw_dbg("NVM Read Error\n"); goto out; } - *part_num |= nvm_data; + + if (length == 0xFFFF || length == 0) { + hw_dbg("NVM PBA number section invalid length\n"); + ret_val = E1000_ERR_NVM_PBA_SECTION; + goto out; + } + /* check if part_num buffer is big enough */ + if (part_num_size < (((u32)length * 2) - 1)) { + hw_dbg("PBA string buffer too small\n"); + ret_val = E1000_ERR_NO_SPACE; + goto out; + } + + /* trim pba length from start of string */ + pointer++; + length--; + + for (offset = 0; offset < length; offset++) { + ret_val = hw->nvm.ops.read(hw, pointer + offset, 1, &nvm_data); + if (ret_val) { + hw_dbg("NVM Read Error\n"); + goto out; + } + part_num[offset * 2] = (u8)(nvm_data >> 8); + part_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF); + } + part_num[offset * 2] = '\0'; out: return ret_val; diff --git a/drivers/net/igb/e1000_nvm.h b/drivers/net/igb/e1000_nvm.h index 1041c34..29c956a 100644 --- a/drivers/net/igb/e1000_nvm.h +++ b/drivers/net/igb/e1000_nvm.h @@ -32,6 +32,8 @@ s32 igb_acquire_nvm(struct e1000_hw *hw); void igb_release_nvm(struct e1000_hw *hw); s32 igb_read_mac_addr(struct e1000_hw *hw); s32 igb_read_part_num(struct e1000_hw *hw, u32 *part_num); +s32 igb_read_part_string(struct e1000_hw *hw, u8 *part_num, + u32 part_num_size); s32 igb_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); s32 igb_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); s32 igb_validate_nvm_checksum(struct e1000_hw *hw); diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index 67ea262..041f8e6 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c @@ -1729,12 +1729,13 @@ static int __devinit igb_probe(struct pci_dev *pdev, struct igb_adapter *adapter; struct e1000_hw *hw; u16 eeprom_data = 0; + s32 ret_val; static int global_quad_port_a; /* global quad port a indication */ const struct e1000_info *ei = igb_info_tbl[ent->driver_data]; unsigned long mmio_start, mmio_len; int err, pci_using_dac; u16 eeprom_apme_mask = IGB_EEPROM_APME; - u32 part_num; + u8 part_str[E1000_PBANUM_LENGTH]; /* Catch broken hardware that put the wrong VF device ID in * the PCIe SR-IOV capability. @@ -2000,10 +2001,10 @@ static int __devinit igb_probe(struct pci_dev *pdev, "unknown"), netdev->dev_addr); - igb_read_part_num(hw, &part_num); - dev_info(&pdev->dev, "%s: PBA No: %06x-%03x\n", netdev->name, - (part_num >> 8), (part_num & 0xff)); - + ret_val = igb_read_part_string(hw, part_str, E1000_PBANUM_LENGTH); + if (ret_val) + strcpy(part_str, "Unknown"); + dev_info(&pdev->dev, "%s: PBA No: %s\n", netdev->name, part_str); dev_info(&pdev->dev, "Using %s interrupts. %d rx queue(s), %d tx queue(s)\n", adapter->msix_entries ? "MSI-X" : -- 1.7.3.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-12-10 20:15 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-12-10 10:06 [net-next-2.6 24/27] e1000e: minor error message corrections Jeff Kirsher 2010-12-10 10:06 ` [net-next-2.6 25/27] e1000e: static analysis tools complain of a possible null ptr p dereference Jeff Kirsher 2010-12-10 12:44 ` Joe Perches 2010-12-10 19:35 ` Tantilov, Emil S 2010-12-10 19:58 ` Joe Perches 2010-12-10 20:16 ` David Miller 2010-12-10 10:06 ` [net-next-2.6 26/27] e1000e: increment the driver version Jeff Kirsher 2010-12-10 10:06 ` [net-next-2.6 27/27] igb: Add new function to read part number from EEPROM in string format Jeff Kirsher
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).