From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id DD2508E9B for ; Thu, 15 Oct 2015 04:04:09 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 14 Oct 2015 19:04:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,683,1437462000"; d="scan'208";a="811315543" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 14 Oct 2015 19:04:08 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t9F246vf004290; Thu, 15 Oct 2015 10:04:06 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t9F243HJ005591; Thu, 15 Oct 2015 10:04:05 +0800 Received: (from wenzhuol@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t9F2437V005587; Thu, 15 Oct 2015 10:04:03 +0800 From: Wenzhuo Lu To: dev@dpdk.org Date: Thu, 15 Oct 2015 10:03:19 +0800 Message-Id: <1444874628-5453-7-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1444874628-5453-1-git-send-email-wenzhuo.lu@intel.com> References: <1444804479-14840-1-git-send-email-wenzhuo.lu@intel.com> <1444874628-5453-1-git-send-email-wenzhuo.lu@intel.com> Subject: [dpdk-dev] [PATCH v2 06/35] e1000/base: add return value to the functions of setting receive address register X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Oct 2015 02:04:11 -0000 Previously, the rar_set functions were of type void, and when they failed to program an address register they would, at most, put a message into the log and end. The fact that they failed to program an address into a address register, if checked for, should be captured and passed back to the caller so that the drivers can deal with the situation (or not) as they deem best. Drivers can ignore or use the return value. No change to base drivers is mandated by this change unless a driver wants to handle the failure to program an address register (e.g. evaluate the return value). Signed-off-by: Wenzhuo Lu --- drivers/net/e1000/base/e1000_82542.c | 6 ++++-- drivers/net/e1000/base/e1000_api.c | 6 ++++-- drivers/net/e1000/base/e1000_api.h | 2 +- drivers/net/e1000/base/e1000_hw.h | 2 +- drivers/net/e1000/base/e1000_ich8lan.c | 18 ++++++++++-------- drivers/net/e1000/base/e1000_mac.c | 12 +++++++----- drivers/net/e1000/base/e1000_mac.h | 2 +- drivers/net/e1000/base/e1000_vf.c | 6 ++++-- drivers/net/e1000/base/e1000_vf.h | 2 +- 9 files changed, 33 insertions(+), 23 deletions(-) diff --git a/drivers/net/e1000/base/e1000_82542.c b/drivers/net/e1000/base/e1000_82542.c index a538cba..4f1183a 100644 --- a/drivers/net/e1000/base/e1000_82542.c +++ b/drivers/net/e1000/base/e1000_82542.c @@ -46,7 +46,7 @@ STATIC s32 e1000_init_hw_82542(struct e1000_hw *hw); STATIC s32 e1000_setup_link_82542(struct e1000_hw *hw); STATIC s32 e1000_led_on_82542(struct e1000_hw *hw); STATIC s32 e1000_led_off_82542(struct e1000_hw *hw); -STATIC void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index); +STATIC int e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index); STATIC void e1000_clear_hw_cntrs_82542(struct e1000_hw *hw); STATIC s32 e1000_read_mac_addr_82542(struct e1000_hw *hw); @@ -410,7 +410,7 @@ STATIC s32 e1000_led_off_82542(struct e1000_hw *hw) * Sets the receive address array register at index to the address passed * in by addr. **/ -STATIC void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index) +STATIC int e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index) { u32 rar_low, rar_high; @@ -431,6 +431,8 @@ STATIC void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index) E1000_WRITE_REG_ARRAY(hw, E1000_RA, (index << 1), rar_low); E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((index << 1) + 1), rar_high); + + return E1000_SUCCESS; } /** diff --git a/drivers/net/e1000/base/e1000_api.c b/drivers/net/e1000/base/e1000_api.c index 5ec0ad1..bbfcae8 100644 --- a/drivers/net/e1000/base/e1000_api.c +++ b/drivers/net/e1000/base/e1000_api.c @@ -831,10 +831,12 @@ void e1000_config_collision_dist(struct e1000_hw *hw) * * Sets a Receive Address Register (RAR) to the specified address. **/ -void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index) +int e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index) { if (hw->mac.ops.rar_set) - hw->mac.ops.rar_set(hw, addr, index); + return hw->mac.ops.rar_set(hw, addr, index); + + return E1000_SUCCESS; } /** diff --git a/drivers/net/e1000/base/e1000_api.h b/drivers/net/e1000/base/e1000_api.h index 53a641c..563d0ca 100644 --- a/drivers/net/e1000/base/e1000_api.h +++ b/drivers/net/e1000/base/e1000_api.h @@ -68,7 +68,7 @@ s32 e1000_setup_link(struct e1000_hw *hw); s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex); s32 e1000_disable_pcie_master(struct e1000_hw *hw); void e1000_config_collision_dist(struct e1000_hw *hw); -void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index); +int e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index); u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr); void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list, u32 mc_addr_count); diff --git a/drivers/net/e1000/base/e1000_hw.h b/drivers/net/e1000/base/e1000_hw.h index 154b9e5..f06be0c 100644 --- a/drivers/net/e1000/base/e1000_hw.h +++ b/drivers/net/e1000/base/e1000_hw.h @@ -699,7 +699,7 @@ struct e1000_mac_operations { s32 (*setup_led)(struct e1000_hw *); void (*write_vfta)(struct e1000_hw *, u32, u32); void (*config_collision_dist)(struct e1000_hw *); - void (*rar_set)(struct e1000_hw *, u8*, u32); + int (*rar_set)(struct e1000_hw *, u8*, u32); s32 (*read_mac_addr)(struct e1000_hw *); s32 (*validate_mdi_setting)(struct e1000_hw *); s32 (*acquire_swfw_sync)(struct e1000_hw *, u16); diff --git a/drivers/net/e1000/base/e1000_ich8lan.c b/drivers/net/e1000/base/e1000_ich8lan.c index cc6e033..228d4c5 100644 --- a/drivers/net/e1000/base/e1000_ich8lan.c +++ b/drivers/net/e1000/base/e1000_ich8lan.c @@ -77,8 +77,8 @@ STATIC s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw); STATIC void e1000_release_nvm_ich8lan(struct e1000_hw *hw); STATIC bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw); STATIC bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw); -STATIC void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index); -STATIC void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index); +STATIC int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index); +STATIC int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index); STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw); #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT STATIC void e1000_update_mc_addr_list_pch2lan(struct e1000_hw *hw, @@ -1750,7 +1750,7 @@ STATIC bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw) * contain the MAC address but RAR[1-6] are reserved for manageability (ME). * Use SHRA[0-3] in place of those reserved for ME. **/ -STATIC void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index) +STATIC int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index) { u32 rar_low, rar_high; @@ -1774,7 +1774,7 @@ STATIC void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index) E1000_WRITE_FLUSH(hw); E1000_WRITE_REG(hw, E1000_RAH(index), rar_high); E1000_WRITE_FLUSH(hw); - return; + return E1000_SUCCESS; } /* RAR[1-6] are owned by manageability. Skip those and program the @@ -1797,7 +1797,7 @@ STATIC void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index) /* verify the register updates */ if ((E1000_READ_REG(hw, E1000_SHRAL(index - 1)) == rar_low) && (E1000_READ_REG(hw, E1000_SHRAH(index - 1)) == rar_high)) - return; + return E1000_SUCCESS; DEBUGOUT2("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n", (index - 1), E1000_READ_REG(hw, E1000_FWSM)); @@ -1805,6 +1805,7 @@ STATIC void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index) out: DEBUGOUT1("Failed to write receive address at index %d\n", index); + return -E1000_ERR_CONFIG; } /** @@ -1818,7 +1819,7 @@ out: * contain the MAC address. SHRA[0-10] are the shared receive address * registers that are shared between the Host and manageability engine (ME). **/ -STATIC void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index) +STATIC int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index) { u32 rar_low, rar_high; u32 wlock_mac; @@ -1842,7 +1843,7 @@ STATIC void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index) E1000_WRITE_FLUSH(hw); E1000_WRITE_REG(hw, E1000_RAH(index), rar_high); E1000_WRITE_FLUSH(hw); - return; + return E1000_SUCCESS; } /* The manageability engine (ME) can lock certain SHRAR registers that @@ -1877,12 +1878,13 @@ STATIC void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index) /* verify the register updates */ if ((E1000_READ_REG(hw, E1000_SHRAL_PCH_LPT(index - 1)) == rar_low) && (E1000_READ_REG(hw, E1000_SHRAH_PCH_LPT(index - 1)) == rar_high)) - return; + return E1000_SUCCESS; } } out: DEBUGOUT1("Failed to write receive address at index %d\n", index); + return -E1000_ERR_CONFIG; } #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT diff --git a/drivers/net/e1000/base/e1000_mac.c b/drivers/net/e1000/base/e1000_mac.c index 5c107c6..a0f3a99 100644 --- a/drivers/net/e1000/base/e1000_mac.c +++ b/drivers/net/e1000/base/e1000_mac.c @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. STATIC s32 e1000_validate_mdi_setting_generic(struct e1000_hw *hw); STATIC void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw); STATIC void e1000_config_collision_dist_generic(struct e1000_hw *hw); -STATIC void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index); +STATIC int e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index); /** * e1000_init_mac_ops_generic - Initialize MAC function pointers @@ -149,15 +149,15 @@ void e1000_null_write_vfta(struct e1000_hw E1000_UNUSEDARG *hw, } /** - * e1000_null_rar_set - No-op function, return void + * e1000_null_rar_set - No-op function, return 0 * @hw: pointer to the HW structure **/ -void e1000_null_rar_set(struct e1000_hw E1000_UNUSEDARG *hw, +int e1000_null_rar_set(struct e1000_hw E1000_UNUSEDARG *hw, u8 E1000_UNUSEDARG *h, u32 E1000_UNUSEDARG a) { DEBUGFUNC("e1000_null_rar_set"); UNREFERENCED_3PARAMETER(hw, h, a); - return; + return E1000_SUCCESS; } /** @@ -469,7 +469,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) * Sets the receive address array register at index to the address passed * in by addr. **/ -STATIC void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index) +STATIC int e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index) { u32 rar_low, rar_high; @@ -495,6 +495,8 @@ STATIC void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index) E1000_WRITE_FLUSH(hw); E1000_WRITE_REG(hw, E1000_RAH(index), rar_high); E1000_WRITE_FLUSH(hw); + + return E1000_SUCCESS; } /** diff --git a/drivers/net/e1000/base/e1000_mac.h b/drivers/net/e1000/base/e1000_mac.h index b5d0940..96a260c 100644 --- a/drivers/net/e1000/base/e1000_mac.h +++ b/drivers/net/e1000/base/e1000_mac.h @@ -44,7 +44,7 @@ s32 e1000_null_link_info(struct e1000_hw *hw, u16 *s, u16 *d); bool e1000_null_mng_mode(struct e1000_hw *hw); void e1000_null_update_mc(struct e1000_hw *hw, u8 *h, u32 a); void e1000_null_write_vfta(struct e1000_hw *hw, u32 a, u32 b); -void e1000_null_rar_set(struct e1000_hw *hw, u8 *h, u32 a); +int e1000_null_rar_set(struct e1000_hw *hw, u8 *h, u32 a); s32 e1000_blink_led_generic(struct e1000_hw *hw); s32 e1000_check_for_copper_link_generic(struct e1000_hw *hw); s32 e1000_check_for_fiber_link_generic(struct e1000_hw *hw); diff --git a/drivers/net/e1000/base/e1000_vf.c b/drivers/net/e1000/base/e1000_vf.c index 3a47d35..7845b48 100644 --- a/drivers/net/e1000/base/e1000_vf.c +++ b/drivers/net/e1000/base/e1000_vf.c @@ -48,7 +48,7 @@ STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed, STATIC s32 e1000_init_hw_vf(struct e1000_hw *hw); STATIC s32 e1000_reset_hw_vf(struct e1000_hw *hw); STATIC void e1000_update_mc_addr_list_vf(struct e1000_hw *hw, u8 *, u32); -STATIC void e1000_rar_set_vf(struct e1000_hw *, u8 *, u32); +STATIC int e1000_rar_set_vf(struct e1000_hw *, u8 *, u32); STATIC s32 e1000_read_mac_addr_vf(struct e1000_hw *); /** @@ -322,7 +322,7 @@ STATIC s32 e1000_init_hw_vf(struct e1000_hw *hw) * @addr: pointer to the receive address * @index receive address array register **/ -STATIC void e1000_rar_set_vf(struct e1000_hw *hw, u8 *addr, +STATIC int e1000_rar_set_vf(struct e1000_hw *hw, u8 *addr, u32 E1000_UNUSEDARG index) { struct e1000_mbx_info *mbx = &hw->mbx; @@ -345,6 +345,8 @@ STATIC void e1000_rar_set_vf(struct e1000_hw *hw, u8 *addr, if (!ret_val && (msgbuf[0] == (E1000_VF_SET_MAC_ADDR | E1000_VT_MSGTYPE_NACK))) e1000_read_mac_addr_vf(hw); + + return E1000_SUCCESS; } /** diff --git a/drivers/net/e1000/base/e1000_vf.h b/drivers/net/e1000/base/e1000_vf.h index 7218212..d6216de 100644 --- a/drivers/net/e1000/base/e1000_vf.h +++ b/drivers/net/e1000/base/e1000_vf.h @@ -207,7 +207,7 @@ struct e1000_mac_operations { s32 (*init_hw)(struct e1000_hw *); s32 (*setup_link)(struct e1000_hw *); void (*write_vfta)(struct e1000_hw *, u32, u32); - void (*rar_set)(struct e1000_hw *, u8*, u32); + int (*rar_set)(struct e1000_hw *, u8*, u32); s32 (*read_mac_addr)(struct e1000_hw *); }; -- 1.9.3