From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0040.outbound.protection.outlook.com [104.47.36.40]) by dpdk.org (Postfix) with ESMTP id 20E16D3E2 for ; Sat, 25 Mar 2017 07:27:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=DvM+BMlvgRAHvHk+C+R53Z/nkTl474gdOoh2fZWtgII=; b=kBGk+Sp3UNto9dJ//rkDTS+R7jQh6P003T5AdycRKr3Da0qdVGtb3wL9XNuT904u3HJbIqPiyqni5zlAJ6Z8eERNas2hEsb5dqAqZUu+CONZjwGD4rYLizdhhTPHnk4zWkPumMIP+y39PFH8HcE9W34lDhTwK+a1gxrPiHH+cnU= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Sat, 25 Mar 2017 06:27:50 +0000 From: Shijith Thotton To: Ferruh Yigit Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Sat, 25 Mar 2017 11:54:30 +0530 Message-Id: <1490423097-6797-20-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BM1PR01CA0117.INDPRD01.PROD.OUTLOOK.COM (10.174.208.33) To CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) X-MS-Office365-Filtering-Correlation-Id: bab31cde-005c-40e1-1a24-08d4734810fb X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 3:W+TA5pIBZrB4zlOCcd0QNVhWW5x6DXHoxqUkIb6RxfQK/aFxiEHMALAinTQsmixpqyhIVSBTwJ0eU3po4SS6mK7CF++wje/ih5OgtdfgTnTbbpuGFuGv83HcTmsy+k2KwKgUOUTKCBHun7hBpOvq/OkXoaSTk8FDTq3pokvDqh57mV8MtnXyvRINaUSeiGxAwGJbjwLGp76KGPDr5Kiy9FltRCl6OtHnKAtO+vn3RsMWmBhfFyEdu5Ng7TAPyLxWpYhhugCNXEwR+61wPCPzzg==; 25:DEjQbH97W3qArpLt8IzB2euhJvxOVCMUKJRt97o8ATIM5Mp60UsDaLytNdHOoiBTgyp6WVtP86FyPyDocJL1BxUFqVceAYqKC+4WMoPsF6YkjH3fBJRrSa8vgklaw+/I441uWEzY8BQ7ECrFJD7Hqd7G9cGAQZLRspZpQYdt41Mzr1FJ0WE+Aq/xtOtymyPk8ewiQumleKbNX4ubS1NLRd+L1+0p7lVyK2UHgo3L5eMQqRAFnOAfVSZybCtetJZby/z9haziXCqQcvyzYcWyvjNbgHY6rLRyg+h5lX+iMH/hWTvH37V8N7pfa7IJ8cBHIKyE3rQS/hgatMnUOLsUGIgM5X+J1/wLNBp7yE12NdFkzuJc7PsIsYWAATYkjrec4yXajG4YgSyU0UxA/+jXEYSLpfg+5KLdbFyXvRl1rOLEPrtWDk+pk/REx/GJk8RlOA28rEWcpsdk06vDDp+KrQ== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 31:Du/U327+3kjVMGXzp4TPX8vgicutyHv3c3Nx4Lhdecgr9w0p5eIswMsJ+HUHwZKaOy/XxUP2BKJ5P1Jj1gPQ+qCAkQS4fhMrZ/J5E8d0YWFwvG6fyOHaKejYZXumFd8LRZeBmntdjzvoNqglM9LxjAFr8eMCZcjciW2muT/nN61JNtSjKyAaFq88a8SVy5Y29J35rCVqDULgKG7HXiGV+TBBXI76Gq5oEE1y7SWa9sD33wS8F16GQBbZ42l9SY3o; 20:2YkYFctacQD+KIVINFLlN+Rv+xbJxmnpTGaOAblrc/LM/SOBbbiiqwn2YR0bnpMcJYjvF8M4z9UZ2lTyDfmUOeG0DIF3n/VhWFQE5LVIwtK9kjLdUxnJ0xBfdMcUa7Eh+42CNcugo8g6uOBuXaR4FRcy35DqWcYcr9yonQ1jIZE7BkBklHXEHYoOf++6gP9NeV2td/l+L0b5nVpnexbdCCqfvhkFdXQZxWSazpt4du+9gkiaEUzfqXoTC9piSH3oe4XDbIIKfbEj9pvtpbVYi1Pe6ljZOPfFNJyLjg6MUF0oAqEB/Is05++i/zk7Wc0BaAIaQnPsPwcFTDYKxqqYhx8t0H2OVwKXzWo0Rq5Ywx8ZkVguX5Pm4RhTdfR+qqNOJPe7afdJyyyre0NFq3RM2GATM4R4zzgXdiQWcSKgG2qpe4R7X/pbX11nRlXRdkTA/MP7Wb3u9/RcXAx1HPVYza5FCfRtyIWv6+vRRoSaodinLXCB/Fejl3MUxnFJ/I7TLjUHTBs7ercQRayWRot3muNmbVwRHc5EKFN1YeyeKmOYqZafetzDKJlqbZT2SYfsIqAF5NIhLsmoYWKSe16o75mlKvUhEAUS6nZJaNO3bT0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123558025)(20161123555025)(6072148); SRVR:CY1PR07MB2280; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 4:zNG/YDkEWzIpiriH8xmt7aJ4O5Ra9s2JEvIrA4Fk/MOFMoXtt0YZejcm+V44XaP5Pna105YcHrky8o5mZAgn2WnG+Xe7vRby3EH4yOxiE72Cgf96DgthQZpRaVS3T7N5j7DkQ8pq0y8WnjAQ03Rtmdvh1sc+30Dxxioryj022oRKXT8h2amhpnHBmZt9Ed6UrPDiwYrEWj4zYegWxBzFl+kwt/+MBSfAfpYo3qTkjtter2KJ+41yUmgHCombYWbFrsnxbHa+5WpjtonwMNUEXoD8mdYmzob4A8lSkqcakp0wv+/x/vuFSRLYnxcI+TsTYiBJ+Zc/yY+fIz0VngyjlVq7AXjAlI46KUmsLkT0ntP8rT4bzYBbxxEGawhEiOSIE2uqBULAbJVn89cx9rURWVCizXYjjUSfilMix+Ib0+zQoHiRSCKo3xGtH6aVGIJ6OKijA7qPsUAEsaNJHtepHLmgC27j6HTtONvU1IJtcGRZZfSsTp1yRKHoZSwme4/Uud0s3Ld4FsYWB0j5zXzbrdW8NOxU/ajZBn4zt2bNWi92ndVMCEoA2dX19FVJNtSxQppmhACOkYOq2I92ViM5/y4EcIubpAf2RDTjKcuOz9g= X-Forefront-PRVS: 025796F161 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(39410400002)(39830400002)(2906002)(2950100002)(5003940100001)(66066001)(575784001)(42882006)(6916009)(50466002)(48376002)(47776003)(42186005)(53936002)(6512007)(68736007)(5009440100003)(54906002)(50226002)(38730400002)(6486002)(6666003)(25786009)(305945005)(81166006)(7736002)(6116002)(3846002)(4326008)(8676002)(6506006)(189998001)(36756003)(50986999)(76176999)(33646002)(4720700003)(5660300001)(110136004)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2280; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2280; 23:yXzWBNrGDDn8VwoB3iBB7ylxxjt73697aCpX89hH6?= =?us-ascii?Q?m6t+OtE19d2vcwUYRiLsSR5vDi03JQ1Hr5IBk1tUvzMjrWAH3yQr/1UQ7Fd4?= =?us-ascii?Q?56QW5YEHBTCQbkFx+YPnujR9tvayEmh8f0AurW9VXDAu24Jcg7XQCd+RVlPG?= =?us-ascii?Q?bRDF37qGG7KVe54mAro/wr5SNk8nhsaH6cVOTm0WNN6yN8tVlTGkBOoy02LE?= =?us-ascii?Q?Cj6eiw7uaVCumlo13+slNGhst9y1/nGPT6JVXJHBMks32lLVjtlrDWSbByn+?= =?us-ascii?Q?WLmG4NuniUw17CAZy2zHqhjVINSFaYLkXCh/HY92qORD5zCUrdjEKj75WaTA?= =?us-ascii?Q?0wxdONO03UQtJYZRsgQlf0dIz6SZORAEAwSPzk5SJXVZrcWTCbIR15tthkWr?= =?us-ascii?Q?JxXloy8YD6iqaXvEcheyjFHcCOLIfMxXVrNfYxl5InzNo40RrY1kgVUwmhOd?= =?us-ascii?Q?7k0Ejj7S/kbKYmWfMLGxpXS1tZkOBwtKIZGrPtJL30cAPs3NWXXx2WSxQKOi?= =?us-ascii?Q?D6EHSqgLj5ne1Zm6zRe7BRMqZkmXBlUF86AzGHZHgPDnTBBCv3xYhwqVIDVf?= =?us-ascii?Q?Lsgy4cmce9KRO9w/DEH3QF7LcnT9PJg1FntYi2wEx21C4Yt7W/JQdsE3QuJe?= =?us-ascii?Q?knrbh/kz0EREwRxGrA6wBt5NknFr2YqqBiJssCVlvGMfJaJUlsYLvcueEOEM?= =?us-ascii?Q?sFxgo4wUCzkLSLVj9skQiNzXn8/qQnYHpllJIpYbQa5LTA75ghbNv5QZz0B8?= =?us-ascii?Q?OdRje9iMytKgnvbfa80lqF7zOnrB/ONFUlF03Xa6PsLfrJSRBMDzaWzylsxs?= =?us-ascii?Q?0VMO4nhdjmXmmimeDgvIAxqhmeHqWps3UTdNRF6e5J1BFBAdExFUkXgSAK3f?= =?us-ascii?Q?ZJ93+Ud4TaAfPn6qaq1Kd6FhvSdCtvjBho6WOUoEfa4uAAyWdLDXhh2uSCqr?= =?us-ascii?Q?QwPlSfTviUv/7TP3ogMaX+jAVTvLCAPrMZciGoSKAifc1rQFXn5jpjL5Fp2N?= =?us-ascii?Q?/xDzxuHzZJ8CMyTP4mKH/ryqzoxWkjEr1M3MmUBHiubGbOJin2KzRUERP0em?= =?us-ascii?Q?PILRNSDFVQ+xlhnkek1KkTXz8GyH9qRVE3d7hCjebO+xSXxpg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 6:1qtRqauI9zyQVXQuxjNfGs18DuB1mpPDdEdLMjQx6SnZO2Q1TW+j3yLcBEYvlQuki+CZOTTFbxFZ+yq90pMF7PwN2hvfvoOLse1MHI+k5C0V+Vh1AoCicYWNjVG9+NmaodZDM3JASdng43JLF3ET2r3yUZWx8BKFf2IhUREkAeSfFQ59ea4GowHY5vi5rEpYVyFZ+6Tzku7yDel7dG7fCGuz9+5qV990NrxfSqs1yg7URGNBOMO4JonxiBg64d3IFD2quP9n+dPUMXEWFgPttKjcxKXQqXQtaie8iZJiXNVgKA1PXIvdhpD6+TiiSmww8rDTLu40rUT2RnmiMRvhSLFxmdzrReRCe93k6MBXlR91Dm5Ce097wHen1cf2H+ZjANjui0deyRWUW3gKIiQH/A==; 5:rD3WASfQ7GgNmZV4RQkSgAix0J7f6qegfcJHoPFSbIZP2HC78S3ULKDFh5qJcoF9ksaRKdlm6IUGvHV+JP3V/uCtU1j4OhvFF6n7gPrM7P8MjnghlLg7JqXccC9nWCroyejpnA+gYpbipaxS5qjtPA==; 24:WOSvUhB+q5Mo0FS97/kgZQTWZGSqWaoZr33jLcOJGhh9t6Eip1i1K7ifhR6Yfhxs4pqf5dZ4sWUsVVredDL9Tj46lyGyOoRbgOFdg0G7WR8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 7:FN+B4wXs7IlltrvI0vPLQvCl9SXhG++n35lwz2C+Y3oTuOgmddpuKC5R7XVELCGU+t+EisZlrYAM9eb6vj9VzKTaIky2vATF4hE9X35cw0Cxh3L+106MpgdLLwNvclLNnHNuIxmm8uU5/B82+aIvwc6cIPDQXONYj/wluXxQUnuogiSEWzgP7me6OBeoLCkyjHS3Lul6VtwJpGzfM8eGHF6ZT5npcf3VQdE92XBvm7apEqLc8iGVX31/6rTUEDdgTW/3DLOeVtiK/n9RYzPZ9MwxuKgCTAOAgVtqRbG1BaRb10JmS2EERbCra3AMvF6jTnPPUbhUae79dA3Ik8AF2A== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2017 06:27:50.2164 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2280 Subject: [dpdk-dev] [PATCH v3 19/46] net/liquidio: add API to configure device 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: Sat, 25 Mar 2017 06:27:55 -0000 Add API to configure device and initialize ethernet device operations. Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Srisivasubramanian S Signed-off-by: Mallesham Jatharakonda --- drivers/net/liquidio/base/lio_hw_defs.h | 14 +++ drivers/net/liquidio/lio_ethdev.c | 169 ++++++++++++++++++++++++++++++++ drivers/net/liquidio/lio_ethdev.h | 36 +++++++ drivers/net/liquidio/lio_struct.h | 72 ++++++++++++++ 4 files changed, 291 insertions(+) diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h index dc11406..3201dc5 100644 --- a/drivers/net/liquidio/base/lio_hw_defs.h +++ b/drivers/net/liquidio/base/lio_hw_defs.h @@ -95,6 +95,8 @@ enum lio_card_type { #define LIO_BASE_MINOR_VERSION 5 #define LIO_BASE_MICRO_VERSION 1 +#define LIO_FW_VERSION_LENGTH 32 + /** Tag types used by Octeon cores in its work. */ enum octeon_tag_type { OCTEON_ORDERED_TAG = 0, @@ -104,6 +106,18 @@ enum octeon_tag_type { /* pre-defined host->NIC tag values */ #define LIO_CONTROL (0x11111110) +/* used for NIC operations */ +#define LIO_OPCODE 1 + +/** LIO_OPCODE subcodes */ +/* This subcode is sent by core PCI driver to indicate cores are ready. */ +#define LIO_OPCODE_IF_CFG 0x09 + +/* Interface flags communicated between host driver and core app. */ +enum lio_ifflags { + LIO_IFFLAG_UNICAST = 0x10 +}; + /* Routines for reading and writing CSRs */ #ifdef RTE_LIBRTE_LIO_DEBUG_REGS #define lio_write_csr(lio_dev, reg_off, value) \ diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 97a7369..194b096 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -41,6 +41,166 @@ #include "lio_ethdev.h" #include "lio_rxtx.h" +static uint64_t +lio_hweight64(uint64_t w) +{ + uint64_t res = w - ((w >> 1) & 0x5555555555555555ul); + + res = + (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); + res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful; + res = res + (res >> 8); + res = res + (res >> 16); + + return (res + (res >> 32)) & 0x00000000000000FFul; +} + +static int lio_dev_configure(struct rte_eth_dev *eth_dev) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + uint16_t timeout = LIO_MAX_CMD_TIMEOUT; + int retval, num_iqueues, num_oqueues; + uint8_t mac[ETHER_ADDR_LEN], i; + struct lio_if_cfg_resp *resp; + struct lio_soft_command *sc; + union lio_if_cfg if_cfg; + uint32_t resp_size; + + PMD_INIT_FUNC_TRACE(); + + /* Re-configuring firmware not supported. + * Can't change tx/rx queues per port from initial value. + */ + if (lio_dev->port_configured) { + if ((lio_dev->nb_rx_queues != eth_dev->data->nb_rx_queues) || + (lio_dev->nb_tx_queues != eth_dev->data->nb_tx_queues)) { + lio_dev_err(lio_dev, + "rxq/txq re-conf not supported. Restart application with new value.\n"); + return -ENOTSUP; + } + return 0; + } + + lio_dev->nb_rx_queues = eth_dev->data->nb_rx_queues; + lio_dev->nb_tx_queues = eth_dev->data->nb_tx_queues; + + resp_size = sizeof(struct lio_if_cfg_resp); + sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0); + if (sc == NULL) + return -ENOMEM; + + resp = (struct lio_if_cfg_resp *)sc->virtrptr; + + /* Firmware doesn't have capability to reconfigure the queues, + * Claim all queues, and use as many required + */ + if_cfg.if_cfg64 = 0; + if_cfg.s.num_iqueues = lio_dev->nb_tx_queues; + if_cfg.s.num_oqueues = lio_dev->nb_rx_queues; + if_cfg.s.base_queue = 0; + + if_cfg.s.gmx_port_id = lio_dev->pf_num; + + lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE, + LIO_OPCODE_IF_CFG, 0, + if_cfg.if_cfg64, 0); + + /* Setting wait time in seconds */ + sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000; + + retval = lio_send_soft_command(lio_dev, sc); + if (retval == LIO_IQ_SEND_FAILED) { + lio_dev_err(lio_dev, "iq/oq config failed status: %x\n", + retval); + /* Soft instr is freed by driver in case of failure. */ + goto nic_config_fail; + } + + /* Sleep on a wait queue till the cond flag indicates that the + * response arrived or timed-out. + */ + while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) { + lio_process_ordered_list(lio_dev); + rte_delay_ms(1); + } + + retval = resp->status; + if (retval) { + lio_dev_err(lio_dev, "iq/oq config failed\n"); + goto nic_config_fail; + } + + lio_swap_8B_data((uint64_t *)(&resp->cfg_info), + sizeof(struct octeon_if_cfg_info) >> 3); + + num_iqueues = lio_hweight64(resp->cfg_info.iqmask); + num_oqueues = lio_hweight64(resp->cfg_info.oqmask); + + if (!(num_iqueues) || !(num_oqueues)) { + lio_dev_err(lio_dev, + "Got bad iqueues (%016lx) or oqueues (%016lx) from firmware.\n", + (unsigned long)resp->cfg_info.iqmask, + (unsigned long)resp->cfg_info.oqmask); + goto nic_config_fail; + } + + lio_dev_dbg(lio_dev, + "interface %d, iqmask %016lx, oqmask %016lx, numiqueues %d, numoqueues %d\n", + eth_dev->data->port_id, + (unsigned long)resp->cfg_info.iqmask, + (unsigned long)resp->cfg_info.oqmask, + num_iqueues, num_oqueues); + + lio_dev->linfo.num_rxpciq = num_oqueues; + lio_dev->linfo.num_txpciq = num_iqueues; + + for (i = 0; i < num_oqueues; i++) { + lio_dev->linfo.rxpciq[i].rxpciq64 = + resp->cfg_info.linfo.rxpciq[i].rxpciq64; + lio_dev_dbg(lio_dev, "index %d OQ %d\n", + i, lio_dev->linfo.rxpciq[i].s.q_no); + } + + for (i = 0; i < num_iqueues; i++) { + lio_dev->linfo.txpciq[i].txpciq64 = + resp->cfg_info.linfo.txpciq[i].txpciq64; + lio_dev_dbg(lio_dev, "index %d IQ %d\n", + i, lio_dev->linfo.txpciq[i].s.q_no); + } + + lio_dev->linfo.hw_addr = resp->cfg_info.linfo.hw_addr; + lio_dev->linfo.gmxport = resp->cfg_info.linfo.gmxport; + lio_dev->linfo.link.link_status64 = + resp->cfg_info.linfo.link.link_status64; + + /* 64-bit swap required on LE machines */ + lio_swap_8B_data(&lio_dev->linfo.hw_addr, 1); + for (i = 0; i < ETHER_ADDR_LEN; i++) + mac[i] = *((uint8_t *)(((uint8_t *)&lio_dev->linfo.hw_addr) + + 2 + i)); + + /* Copy the permanent MAC address */ + ether_addr_copy((struct ether_addr *)mac, ð_dev->data->mac_addrs[0]); + + lio_dev->port_configured = 1; + + lio_free_soft_command(sc); + + return 0; + +nic_config_fail: + lio_dev_err(lio_dev, "Failed retval %d\n", retval); + lio_free_soft_command(sc); + lio_free_instr_queue0(lio_dev); + + return -ENODEV; +} + +/* Define our ethernet definitions */ +static const struct eth_dev_ops liovf_eth_dev_ops = { + .dev_configure = lio_dev_configure, +}; + static void lio_check_pf_hs_response(void *lio_dev) { @@ -215,13 +375,22 @@ return -EINVAL; } + eth_dev->dev_ops = &liovf_eth_dev_ops; eth_dev->data->mac_addrs = rte_zmalloc("lio", ETHER_ADDR_LEN, 0); if (eth_dev->data->mac_addrs == NULL) { lio_dev_err(lio_dev, "MAC addresses memory allocation failed\n"); + eth_dev->dev_ops = NULL; return -ENOMEM; } + rte_atomic64_set(&lio_dev->status, LIO_DEV_RUNNING); + rte_wmb(); + + lio_dev->port_configured = 0; + /* Always allow unicast packets */ + lio_dev->ifflags |= LIO_IFFLAG_UNICAST; + return 0; } diff --git a/drivers/net/liquidio/lio_ethdev.h b/drivers/net/liquidio/lio_ethdev.h index 76c9072..22e3d83 100644 --- a/drivers/net/liquidio/lio_ethdev.h +++ b/drivers/net/liquidio/lio_ethdev.h @@ -36,5 +36,41 @@ #include +#include "lio_struct.h" + +#define LIO_MAX_CMD_TIMEOUT 10000 /* 10000ms (10s) */ + #define LIO_DEV(_eth_dev) ((_eth_dev)->data->dev_private) + +struct octeon_if_cfg_info { + uint64_t iqmask; /** mask for IQs enabled for the port */ + uint64_t oqmask; /** mask for OQs enabled for the port */ + struct octeon_link_info linfo; /** initial link information */ + char lio_firmware_version[LIO_FW_VERSION_LENGTH]; +}; + +union lio_if_cfg { + uint64_t if_cfg64; + struct { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint64_t base_queue : 16; + uint64_t num_iqueues : 16; + uint64_t num_oqueues : 16; + uint64_t gmx_port_id : 8; + uint64_t vf_id : 8; +#else + uint64_t vf_id : 8; + uint64_t gmx_port_id : 8; + uint64_t num_oqueues : 16; + uint64_t num_iqueues : 16; + uint64_t base_queue : 16; +#endif + } s; +}; + +struct lio_if_cfg_resp { + uint64_t rh; + struct octeon_if_cfg_info cfg_info; + uint64_t status; +}; #endif /* _LIO_ETHDEV_H_ */ diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h index f16571b..48c4cae 100644 --- a/drivers/net/liquidio/lio_struct.h +++ b/drivers/net/liquidio/lio_struct.h @@ -274,6 +274,75 @@ struct lio_config { int def_rx_buf_size; }; +/** Status of a RGMII Link on Octeon as seen by core driver. */ +union octeon_link_status { + uint64_t link_status64; + + struct { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint64_t duplex : 8; + uint64_t mtu : 16; + uint64_t speed : 16; + uint64_t link_up : 1; + uint64_t autoneg : 1; + uint64_t if_mode : 5; + uint64_t pause : 1; + uint64_t flashing : 1; + uint64_t reserved : 15; +#else + uint64_t reserved : 15; + uint64_t flashing : 1; + uint64_t pause : 1; + uint64_t if_mode : 5; + uint64_t autoneg : 1; + uint64_t link_up : 1; + uint64_t speed : 16; + uint64_t mtu : 16; + uint64_t duplex : 8; +#endif + } s; +}; + +/** The rxpciq info passed to host from the firmware */ +union octeon_rxpciq { + uint64_t rxpciq64; + + struct { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint64_t q_no : 8; + uint64_t reserved : 56; +#else + uint64_t reserved : 56; + uint64_t q_no : 8; +#endif + } s; +}; + +/** Information for a OCTEON ethernet interface shared between core & host. */ +struct octeon_link_info { + union octeon_link_status link; + uint64_t hw_addr; + +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint64_t gmxport : 16; + uint64_t macaddr_is_admin_assigned : 1; + uint64_t vlan_is_admin_assigned : 1; + uint64_t rsvd : 30; + uint64_t num_txpciq : 8; + uint64_t num_rxpciq : 8; +#else + uint64_t num_rxpciq : 8; + uint64_t num_txpciq : 8; + uint64_t rsvd : 30; + uint64_t vlan_is_admin_assigned : 1; + uint64_t macaddr_is_admin_assigned : 1; + uint64_t gmxport : 16; +#endif + + union octeon_txpciq txpciq[LIO_MAX_IOQS_PER_IF]; + union octeon_rxpciq rxpciq[LIO_MAX_IOQS_PER_IF]; +}; + /* ----------------------- THE LIO DEVICE --------------------------- */ /** The lio device. * Each lio device has this structure to represent all its @@ -294,6 +363,8 @@ struct lio_device { /** The state of this device */ rte_atomic64_t status; + struct octeon_link_info linfo; + uint8_t *hw_addr; struct lio_fn_list fn_list; @@ -324,6 +395,7 @@ struct lio_device { struct rte_eth_dev *eth_dev; + uint64_t ifflags; uint8_t max_rx_queues; uint8_t max_tx_queues; uint8_t nb_rx_queues; -- 1.8.3.1