From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id BE65B1288 for ; Tue, 9 Jun 2015 18:44:40 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 09 Jun 2015 09:23:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,581,1427785200"; d="scan'208";a="708010375" Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91]) by orsmga001.jf.intel.com with ESMTP; 09 Jun 2015 09:23:53 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 10 Jun 2015 00:23:49 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.246]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.46]) with mapi id 14.03.0224.002; Wed, 10 Jun 2015 00:23:48 +0800 From: "Qiu, Michael" To: "Chen, Jing D" , "dev@dpdk.org" Thread-Topic: [PATCH 4/6] fm10k: Fix issue that MAC addr can't be set to silicon Thread-Index: AQHQmecLDveinEFR5k6CRP8I2o2hLg== Date: Tue, 9 Jun 2015 16:23:47 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E6028604695A13@SHSMSX101.ccr.corp.intel.com> References: <1432887044-24777-1-git-send-email-jing.d.chen@intel.com> <1432887044-24777-5-git-send-email-jing.d.chen@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "He, Shaopeng" Subject: Re: [dpdk-dev] [PATCH 4/6] fm10k: Fix issue that MAC addr can't be set to silicon 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: Tue, 09 Jun 2015 16:44:41 -0000 On 2015/5/29 16:11, Chen, Jing D wrote:=0A= > From: "Chen Jing D(Mark)" =0A= >=0A= > In fm10k, PF driver needs to communicate with switch through=0A= > mailbox if it needs to add/delete MAC address.=0A= > This fix will validate if switch is ready before going forward.=0A= > Then, it is necessary to acquire LPORT_MAP info after issuing=0A= > MAC addr request to switch.=0A= >=0A= > Signed-off-by: Chen Jing D(Mark) =0A= > ---=0A= > drivers/net/fm10k/fm10k_ethdev.c | 34 +++++++++++++++++++++++++++++++-= --=0A= > 1 files changed, 31 insertions(+), 3 deletions(-)=0A= >=0A= > diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_e= thdev.c=0A= > index 19e718b..dedfbb4 100644=0A= > --- a/drivers/net/fm10k/fm10k_ethdev.c=0A= > +++ b/drivers/net/fm10k/fm10k_ethdev.c=0A= > @@ -45,6 +45,10 @@=0A= > #define FM10K_MBXLOCK_DELAY_US 20=0A= > #define UINT64_LOWER_32BITS_MASK 0x00000000ffffffffULL=0A= > =0A= > +/* Max try times to aquire switch status */=0A= > +#define MAX_QUERY_SWITCH_STATE_TIMES 10=0A= > +/* Wait interval to get switch status */=0A= > +#define WAIT_SWITCH_MSG_US 100000=0A= > /* Number of chars per uint32 type */=0A= > #define CHARS_PER_UINT32 (sizeof(uint32_t))=0A= > #define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)=0A= > @@ -1802,6 +1806,32 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)=0A= > fm10k_dev_enable_intr_vf(dev);=0A= > }=0A= > =0A= > + /* Enable uio intr after callback registered */=0A= > + rte_intr_enable(&(dev->pci_dev->intr_handle));=0A= > +=0A= > + hw->mac.ops.update_int_moderator(hw);=0A= > +=0A= > + /* Make sure Switch Manager is ready before going forward. */=0A= > + if (hw->mac.type =3D=3D fm10k_mac_pf) {=0A= > + int switch_ready =3D 0;=0A= > + int i;=0A= > +=0A= > + for (i =3D 0; i < MAX_QUERY_SWITCH_STATE_TIMES; i++) {=0A= > + fm10k_mbx_lock(hw);=0A= > + hw->mac.ops.get_host_state(hw, &switch_ready);=0A= > + fm10k_mbx_unlock(hw);=0A= > + if (switch_ready)=0A= > + break;=0A= > + /* Delay some time to acquire async LPORT_MAP info. */=0A= > + rte_delay_us(WAIT_SWITCH_MSG_US);=0A= > + }=0A= > +=0A= > + if (switch_ready =3D=3D 0) {=0A= > + PMD_INIT_LOG(ERR, "switch is not ready");=0A= > + return -1;=0A= =0A= Here better to return -EIO or other error code? "-1" seems not keep the=0A= same style with other return routine in this function.=0A= =0A= Thanks,=0A= Michael=0A= =0A= =0A= > + }=0A= > + }=0A= > +=0A= > /*=0A= > * Below function will trigger operations on mailbox, acquire lock to= =0A= > * avoid race condition from interrupt handler. Operations on mailbox= =0A= > @@ -1811,7 +1841,7 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)=0A= > */=0A= > fm10k_mbx_lock(hw);=0A= > /* Enable port first */=0A= > - hw->mac.ops.update_lport_state(hw, 0, 0, 1);=0A= > + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, 1, 1);=0A= > =0A= > /* Update default vlan */=0A= > hw->mac.ops.update_vlan(hw, hw->mac.default_vid, 0, true);=0A= > @@ -1831,8 +1861,6 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)=0A= > =0A= > fm10k_mbx_unlock(hw);=0A= > =0A= > - /* enable uio intr after callback registered */=0A= > - rte_intr_enable(&(dev->pci_dev->intr_handle));=0A= > =0A= > return 0;=0A= > }=0A= =0A=