aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ice/ice_common.c
diff options
context:
space:
mode:
authorMd Fahad Iqbal Polash <md.fahad.iqbal.polash@intel.com>2018-04-16 13:07:03 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2018-04-24 15:27:49 -0400
commitd6fef10c750e64f248543d2eee7c86a4a019f7ec (patch)
treeafc05242bbd227d34078b7a49ef33c1bab38b13d /drivers/net/ethernet/intel/ice/ice_common.c
parent30d84397affb0fcb11beaf049caabfcb1dac65a6 (diff)
ice: Fix insufficient memory issue in ice_aq_manage_mac_read
For the MAC read operation, the device can return up to two (LAN and WoL) MAC addresses. Without access to adequate memory, the device will return an error. Fixed this by allocating the right amount of memory. Also, logic to detect and copy the LAN MAC address into the port_info structure has been added. Note that the WoL MAC address is ignored currently as the WoL feature isn't supported yet. Fixes: dc49c7723676 ("ice: Get MAC/PHY/link info and scheduler topology") Signed-off-by: Md Fahad Iqbal Polash <md.fahad.iqbal.polash@intel.com> Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> Tested-by: Tony Brelinski <tonyx.brelinski@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_common.c')
-rw-r--r--drivers/net/ethernet/intel/ice/ice_common.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 21977ec984c4..71d032cc5fa7 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -78,6 +78,7 @@ ice_aq_manage_mac_read(struct ice_hw *hw, void *buf, u16 buf_size,
78 struct ice_aq_desc desc; 78 struct ice_aq_desc desc;
79 enum ice_status status; 79 enum ice_status status;
80 u16 flags; 80 u16 flags;
81 u8 i;
81 82
82 cmd = &desc.params.mac_read; 83 cmd = &desc.params.mac_read;
83 84
@@ -98,8 +99,16 @@ ice_aq_manage_mac_read(struct ice_hw *hw, void *buf, u16 buf_size,
98 return ICE_ERR_CFG; 99 return ICE_ERR_CFG;
99 } 100 }
100 101
101 ether_addr_copy(hw->port_info->mac.lan_addr, resp->mac_addr); 102 /* A single port can report up to two (LAN and WoL) addresses */
102 ether_addr_copy(hw->port_info->mac.perm_addr, resp->mac_addr); 103 for (i = 0; i < cmd->num_addr; i++)
104 if (resp[i].addr_type == ICE_AQC_MAN_MAC_ADDR_TYPE_LAN) {
105 ether_addr_copy(hw->port_info->mac.lan_addr,
106 resp[i].mac_addr);
107 ether_addr_copy(hw->port_info->mac.perm_addr,
108 resp[i].mac_addr);
109 break;
110 }
111
103 return 0; 112 return 0;
104} 113}
105 114
@@ -464,9 +473,12 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
464 if (status) 473 if (status)
465 goto err_unroll_sched; 474 goto err_unroll_sched;
466 475
467 /* Get port MAC information */ 476 /* Get MAC information */
468 mac_buf_len = sizeof(struct ice_aqc_manage_mac_read_resp); 477 /* A single port can report up to two (LAN and WoL) addresses */
469 mac_buf = devm_kzalloc(ice_hw_to_dev(hw), mac_buf_len, GFP_KERNEL); 478 mac_buf = devm_kcalloc(ice_hw_to_dev(hw), 2,
479 sizeof(struct ice_aqc_manage_mac_read_resp),
480 GFP_KERNEL);
481 mac_buf_len = 2 * sizeof(struct ice_aqc_manage_mac_read_resp);
470 482
471 if (!mac_buf) { 483 if (!mac_buf) {
472 status = ICE_ERR_NO_MEMORY; 484 status = ICE_ERR_NO_MEMORY;