From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0089.outbound.protection.outlook.com [104.47.42.89]) by dpdk.org (Postfix) with ESMTP id 28DBB4D27 for ; Fri, 7 Sep 2018 17:23:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=AQUANTIA1COM.onmicrosoft.com; s=selector1-aquantia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FYiKhT5MEZ5uKsjWOXSIAb4v6d+LC5M1ueqN6BMeO4k=; b=tPZgzHFkneTUzYFWyzmhZ6LKF/SWddwXCJyjfHytRsI0GrDse6zikqL9cVVuNzPtx4Mtyi7TsRyykATTHU2ku3Kqi4Hg0V9aYdCdzMQa6kByTDpX/kjOI9m+pIEwRZgkWVRfo+9MPSuPFMyCkUdcaM6bjvIb07RI3eaRFJ6vmeQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; Received: from ubuntubox.rdc.aquantia.com (95.79.108.179) by BLUPR0701MB1652.namprd07.prod.outlook.com (2a01:111:e400:58c6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 7 Sep 2018 15:23:16 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, Nadezhda.Krupnina@aquantia.com, igor.russkikh@aquantia.com, Simon.Edelhaus@aquantia.com, Corey Melton , Ashish Kumar Date: Fri, 7 Sep 2018 18:21:46 +0300 Message-Id: <1536333719-32155-9-git-send-email-igor.russkikh@aquantia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536333719-32155-1-git-send-email-igor.russkikh@aquantia.com> References: <1536333719-32155-1-git-send-email-igor.russkikh@aquantia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.79.108.179] X-ClientProxiedBy: BN6PR20CA0060.namprd20.prod.outlook.com (2603:10b6:404:151::22) To BLUPR0701MB1652.namprd07.prod.outlook.com (2a01:111:e400:58c6::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b37e4703-0a89-4424-da1e-08d614d5d653 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1652; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1652; 3:2wCHbWYHezyME0ArJYVUJsnwvoredB6qJ3bj9taWlt/aqW6FHlRYRVFgtsffRJw1qx75AnTE0VjbQMtHb6FoPbwXphy/V4pkSjzPcph72Vm3nQzs5IMaaM9+XI9cIg8fRhgxCzBosjqSY8nKxXY2RE/IIO3Tr3QOL/1x2F+FPNwvDOmfDm1i+CJ/YV60F4S9X/F/xYXOm7BNGMwSfUphJFkJ6qGFVeGGpd/OlgN4qoGggfJgWqB1Q5NStNr6Jj8D; 25:uXKHI+KLkSbB5KBd1DtaTS2om/m0eE1R1U2FastxzBcjT6LQBPOSNQsf9giDtZHwlUVLb69RsKZ2O39KluPM5uRWDE3quKlsehK9eDlkH3QxHmghO80AD8lzGjGRv2mdxSwjmphb3iRDpSTVrek+YSmEDInYntQjnDsHuhun3ioCtJriFmMCebY9JdVR1DsIroeu6mZryosSXs+dO6KHeAtFRa7CrRG2Osa3TZZORZVnJtq/ZF5qU4247X5L++Sjp6IZZEDiMRqsJH1I9aoIMc8rOTA4HouqqowCss9PST2GLYIbnI3gZU6S829BJaMXedk9BgAzmjA1BqMsDr/cPA==; 31:uuA7hnuqGAqm+FM0yNnMkrx6Nu0yU94hiYnVmOSVsDuDuyCmbVeBSEudphEo1pUs/KqGfyiPy9oeT+eBOAQiXkri6HCYtn2fkgpp7gWYvGv1MslHmNBWYdw29ZvnZ2CKyKplqF8YWCy2lh0jRhXJ0NEScCNoaNczMXfuyfPIEf0LDhOXc4Wb6GwLT0Lech98DJkj3ur2EkHUSn/Xw9cXeWcsXQaj1FqrHjHcplLvXt0= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1652: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1652; 20:ku7zrXB0l+znzDsgtzFKy06fqaElLiFLGkb/oyXjI8nR1cPNPUOPSRnhQFwAkyNOFNv1/sMF++bXxArNgXB6R200b+0OKTn0IfzgTXV3ps7B+Xfpii+TQenYUh6F3xZDWF0t6y7yhomKXNDyvhXPe2rB3gZBEblLq6pnVv9/277pQfAwJ9u0i7xOVtlypvBsEMSwKdo80NiCa3fvfbCXfJ/7GgQGW+OD2SwWiB7AgyFyXhpxxa8VB47BwHuscDSiJhkDVxIdaidkXctO8wQPfLhQm6AfhrCmQwez7vujvrQHnHgatY3JwUaX5dkERlN3oBrjzICK9HxaGXlkCzbJ14y9uPRn/ZZAFrRyUojNYDB85rAx00wZlRrc0uHUpHpXQNNXPJt0Y4pxez+QdgZPKADIebUFcnGUxueBarF44JVoettrR3V9IDM2rcAZR7NKgFwXWRDGDoQxOrIIi6fkmsV+8Z99Ae4DvbTqapYH0F9WLbLbVYRbJPdBcVwYBEEe; 4:Ul5a03FMrPviiaHnn+5p9s4P7FyfS0q12fIzZXuN181nq4hWi6z2wPbtkwxjuwa3nzGSBRmwjSUeq38C8NFbu1zptAh8C2PgGKpwyEol1nCbvbFskqN7wWnzUVCLCteCN/B1y75FhsoMZEMs9t8RYYLhfFxyIcZ+NyT+sPqR0bHDXsPCap7AgKt4HBLrcyMdAm8nHmBLmnB4JPMY/OW4OOfcXlJtvXL60fbfEQekiyIZ/O6rnkH8gArJQLfMul2j4e9rpKDIpAnn9v8CTO9Jdh6jcEihW7TRCcEBjpxFj5Q6Dn5kSAXaF1o4HpgkYYBMSnsxfJfGqOwonh3o977ebiV3pDOrmf6Bk2VJDG8irrw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705)(211171220733660); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699050); SRVR:BLUPR0701MB1652; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1652; X-Forefront-PRVS: 07880C4932 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39850400004)(396003)(376002)(366004)(346002)(136003)(189003)(199004)(81156014)(81166006)(44832011)(8936002)(2351001)(486006)(106356001)(2361001)(105586002)(446003)(2906002)(50226002)(476003)(11346002)(956004)(2616005)(305945005)(7736002)(16586007)(316002)(54906003)(14444005)(16526019)(66066001)(26005)(7696005)(52116002)(8676002)(51416003)(76176011)(186003)(386003)(68736007)(478600001)(6666003)(6916009)(6486002)(5660300001)(53936002)(47776003)(4326008)(25786009)(86362001)(48376002)(50466002)(72206003)(6116002)(97736004)(36756003)(3846002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1652; H:ubuntubox.rdc.aquantia.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1652; 23:x7N7wynRs0KnWduBuphd5y7J3VWL/afKFYl1QNY?= =?us-ascii?Q?JR0M11b1Z27G3HOYwQh/JOawQ5YN3exMYVHH0JculMjYRliiwuMAPC+AhgY/?= =?us-ascii?Q?OOKNGEOsQPrMBYxZQynMo9IAEW2Huc1UxKhkp0mfYdZkrMkx81qHIdyO5cdC?= =?us-ascii?Q?8PhsX3pM9nbowUx+b3c/C84V33gBVc2CDvuKpCwMyms5mW1glkBjC+BGgDFb?= =?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R62xAmB1SYE8vWUxHL1OFdqrdUNN1zgw==; 5:0CTSWqXJ1gCESf7X0OZ9y4IIQ551UQhUmqoVmfRSuXBNBtld7I4eGLtFaHWAeV+oyCYA6oQAQzzHzlubfpAAAiIVgb85Qb5MtfLG+4DObZhDgQgwW9QT2nAXCctMaywxQ4kSLqsUPz7cikzQXFn0Wt/LPR29lIHGnwKRWjRwU9A=; 7:JFR+l4O0zKpOwDf3QmBmyOm+bOUc86UTMejbeFjOGnLZtqQzeKuy89SaQmXHXQ4+1d1mE1qKRm34t1JxZD5LQvRr4frHte3J5kODhplTLFdCxqLDxVfNBNZzhsc2SUMhsBf2vNdCmsifm+jeHrSVKUPqGGz2TFsvs1fjzLr5Tn+iFbELyvukZmEhvFIpNysBKKiYjZdkeC36sVgpW7JAS3/e9baw9KmENRryq27IARQk4HJnIvGUkYgDGKYmLoUR SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2018 15:23:16.2501 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b37e4703-0a89-4424-da1e-08d614d5d653 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1652 Subject: [dpdk-dev] [PATCH 08/21] net/atlantic: rte device start, stop, initial configuration X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Sep 2018 15:23:24 -0000 Start, stop and reset are all done via hw_atl layer. Link interrupt configuration is also done here. Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 253 ++++++++++++++++++++++++++++++++++++++ drivers/net/atlantic/atl_ethdev.h | 2 + 2 files changed, 255 insertions(+) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 31ff50f18..78438174e 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -39,6 +39,9 @@ #include "atl_common.h" #include "atl_hw_regs.h" #include "atl_logs.h" +#include "hw_atl/hw_atl_llh.h" +#include "hw_atl/hw_atl_b0.h" +#include "hw_atl/hw_atl_b0_internal.h" static int eth_atl_dev_init(struct rte_eth_dev *eth_dev); static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev); @@ -126,6 +129,26 @@ static const struct eth_dev_ops atl_eth_dev_ops = { .dev_reset = atl_dev_reset, }; +static inline int32_t +atl_reset_hw(struct aq_hw_s *hw) +{ + return hw_atl_b0_hw_reset(hw); +} + +static inline void +atl_enable_intr(struct rte_eth_dev *dev) +{ + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + hw_atl_itr_irq_msk_setlsw_set(hw, 0xffffffff); +} + +static void +atl_disable_intr(struct aq_hw_s *hw) +{ + PMD_INIT_FUNC_TRACE(); + hw_atl_itr_irq_msk_clearlsw_set(hw, 0xffffffff); +} static int atl_get_bus_info(struct aq_hw_s *hw) @@ -136,6 +159,16 @@ atl_get_bus_info(struct aq_hw_s *hw) return 0; } +static void +atl_print_adapter_info(struct aq_hw_s *hw __rte_unused) +{ + PMD_INIT_LOG(DEBUG, "FW version: %u.%u.%u", + hw->fw_ver_actual >> 24, + (hw->fw_ver_actual >> 16) & 0xFF, + hw->fw_ver_actual & 0xFFFF); + PMD_INIT_LOG(DEBUG, "Driver version: %s", ATL_PMD_DRIVER_VERSION); +} + static int eth_atl_dev_init(struct rte_eth_dev *eth_dev) { @@ -157,6 +190,60 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) return 0; } + rte_eth_copy_pci_info(eth_dev, pci_dev); + + /* Vendor and Device ID need to be set before init of shared code */ + hw->device_id = pci_dev->id.device_id; + hw->vendor_id = pci_dev->id.vendor_id; + hw->mmio = (void *)pci_dev->mem_resource[0].addr; + hw->allow_unsupported_sfp = 1; + + /* Hardware configuration - hardcode */ + adapter->hw_cfg.is_lro = false; + adapter->hw_cfg.is_rss = false; + adapter->hw_cfg.num_rss_queues = HW_ATL_B0_RSS_MAX; + adapter->hw_cfg.wol = false; + adapter->hw_cfg.link_speed_msk = AQ_NIC_RATE_10G| + AQ_NIC_RATE_5G| + AQ_NIC_RATE_2G5| + AQ_NIC_RATE_1G| + AQ_NIC_RATE_100M; + + adapter->hw_cfg.flow_control = (AQ_NIC_FC_RX | AQ_NIC_FC_TX); + adapter->hw_cfg.aq_rss.indirection_table_size = HW_ATL_B0_RSS_REDIRECTION_MAX; + + hw->aq_nic_cfg = &adapter->hw_cfg; + + /* pick up the PCI bus settings for reporting later */ + atl_get_bus_info(hw); + + /* disable interrupt */ + atl_disable_intr(hw); + + /* Allocate memory for storing MAC addresses */ + eth_dev->data->mac_addrs = rte_zmalloc("atlantic", ETHER_ADDR_LEN, 0); + if (eth_dev->data->mac_addrs == NULL) { + PMD_INIT_LOG(ERR, "MAC Malloc failed"); + return -ENOMEM; + } + + err = hw_atl_utils_initfw(hw, &hw->aq_fw_ops); + if (err) + return err; + + /* Copy the permanent MAC address */ + if (hw->aq_fw_ops->get_mac_permanent(hw, (u8*)ð_dev->data->mac_addrs[0]) != 0) + return -EINVAL; + + rte_intr_callback_register(intr_handle, + atl_dev_interrupt_handler, eth_dev); + + /* enable uio/vfio intr/eventfd mapping */ + rte_intr_enable(intr_handle); + + /* enable support intr */ + atl_enable_intr(eth_dev); + return err; } @@ -172,10 +259,30 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return -EPERM; + hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + + if (hw->adapter_stopped == 0) + atl_dev_close(eth_dev); + eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; + /* disable uio intr before callback unregister */ + rte_intr_disable(intr_handle); + rte_intr_callback_unregister(intr_handle, + atl_dev_interrupt_handler, eth_dev); + + rte_free(eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs = NULL; + + rte_free(eth_dev->data->hash_mac_addrs); + eth_dev->data->hash_mac_addrs = NULL; + +#ifdef RTE_LIBRTE_SECURITY + rte_free(eth_dev->security_ctx); +#endif + return 0; } @@ -198,6 +305,11 @@ atl_dev_configure(struct rte_eth_dev *dev) { struct atl_interrupt *intr = ATL_DEV_PRIVATE_TO_INTR(dev->data->dev_private); + PMD_INIT_FUNC_TRACE(); + + /* set flag to update link status after init */ + intr->flags |= ATL_FLAG_NEED_LINK_UPDATE; + return 0; } @@ -218,6 +330,33 @@ atl_dev_start(struct rte_eth_dev *dev) int status; int err; + PMD_INIT_FUNC_TRACE(); + + if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) { + PMD_INIT_LOG(ERR, + "Invalid link_speeds for port %u, fix speed not supported", + dev->data->port_id); + return -EINVAL; + } + + /* disable uio/vfio intr/eventfd mapping */ + rte_intr_disable(intr_handle); + + /* stop adapter */ + hw->adapter_stopped = 0; + + /* reinitialize adapter + * this calls reset and start + */ + status = atl_reset_hw(hw); + if (status != 0) { + return -1; + } + + err = hw_atl_b0_hw_init(hw, (uint8_t*)dev->data->mac_addrs); + + hw_atl_b0_hw_start(hw); + /* check and configure queue intr-vector mapping */ if ((rte_intr_cap_multiple(intr_handle) || !RTE_ETH_DEV_SRIOV(dev).active) && @@ -244,6 +383,33 @@ atl_dev_start(struct rte_eth_dev *dev) } } + if (rte_intr_allow_others(intr_handle)) { + /* check if lsc interrupt is enabled */ + if (dev->data->dev_conf.intr_conf.lsc != 0) + atl_dev_lsc_interrupt_setup(dev, TRUE); + else + atl_dev_lsc_interrupt_setup(dev, FALSE); + } else { + rte_intr_callback_unregister(intr_handle, + atl_dev_interrupt_handler, dev); + if (dev->data->dev_conf.intr_conf.lsc != 0) + PMD_INIT_LOG(INFO, "lsc won't enable because of" + " no intr multiplex"); + } + + /* check if rxq interrupt is enabled */ + if (dev->data->dev_conf.intr_conf.rxq != 0 && + rte_intr_dp_is_en(intr_handle)) + atl_dev_rxq_interrupt_setup(dev); + + /* enable uio/vfio intr/eventfd mapping */ + rte_intr_enable(intr_handle); + + /* resume enabled intr since hw reset */ + atl_enable_intr(dev); + + atl_print_adapter_info(hw); + return 0; error: @@ -257,7 +423,40 @@ atl_dev_start(struct rte_eth_dev *dev) static void atl_dev_stop(struct rte_eth_dev *dev) { + struct rte_eth_link link; + struct aq_hw_s *hw = + ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; + PMD_INIT_FUNC_TRACE(); + + /* disable interrupts */ + atl_disable_intr(hw); + + /* reset the NIC */ + atl_reset_hw(hw); + hw->adapter_stopped = 0; + /* Clear stored conf */ + dev->data->scattered_rx = 0; + dev->data->lro = 0; + + /* Clear recorded link status */ + memset(&link, 0, sizeof(link)); + rte_atl_dev_atomic_write_link_status(dev, &link); + + if (!rte_intr_allow_others(intr_handle)) + /* resume to the default handler */ + rte_intr_callback_register(intr_handle, + atl_dev_interrupt_handler, + (void *)dev); + + /* Clean datapath event and queue/vec mapping */ + rte_intr_efd_disable(intr_handle); + if (intr_handle->intr_vec != NULL) { + rte_free(intr_handle->intr_vec); + intr_handle->intr_vec = NULL; + } } /* @@ -270,6 +469,8 @@ atl_dev_close(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); + atl_reset_hw(hw); + atl_dev_stop(dev); hw->adapter_stopped = 1; } @@ -288,6 +489,58 @@ atl_dev_reset(struct rte_eth_dev *dev) return ret; } + +/* + * It executes link_update after knowing an interrupt occurred. + * + * @param dev + * Pointer to struct rte_eth_dev. + * + * @return + * - On success, zero. + * - On failure, a negative value. + */ +static int +atl_dev_interrupt_action(struct rte_eth_dev *dev, + struct rte_intr_handle *intr_handle) +{ + struct atl_interrupt *intr = + ATL_DEV_PRIVATE_TO_INTR(dev->data->dev_private); + + if (intr->flags & ATL_FLAG_NEED_LINK_UPDATE) { + atl_dev_link_update(dev, 0); + intr->flags &= ~ATL_FLAG_NEED_LINK_UPDATE; + atl_dev_link_status_print(dev); + _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); + } + + atl_enable_intr(dev); + rte_intr_enable(intr_handle); + + return 0; +} + +/** + * Interrupt handler triggered by NIC for handling + * specific interrupt. + * + * @param handle + * Pointer to interrupt handle. + * @param param + * The address of parameter (struct rte_eth_dev *) regsitered before. + * + * @return + * void + */ +static void +atl_dev_interrupt_handler(void *param) +{ + struct rte_eth_dev *dev = (struct rte_eth_dev *)param; + + atl_dev_interrupt_get_status(dev); + atl_dev_interrupt_action(dev, dev->intr_handle); +} + RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map); RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic"); diff --git a/drivers/net/atlantic/atl_ethdev.h b/drivers/net/atlantic/atl_ethdev.h index 18a814a32..0018fa898 100644 --- a/drivers/net/atlantic/atl_ethdev.h +++ b/drivers/net/atlantic/atl_ethdev.h @@ -20,6 +20,8 @@ * Structure to store private data for each driver instance (for each port). */ struct atl_adapter { + struct aq_hw_s hw; + struct aq_hw_cfg_s hw_cfg; }; #define ATL_DEV_TO_ADAPTER(dev) \ -- 2.13.3.windows.1