From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0073.outbound.protection.outlook.com [104.47.40.73]) by dpdk.org (Postfix) with ESMTP id 2572DF963 for ; Thu, 2 Mar 2017 12:38:56 +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=DyhcypC2cZzWQks/hAcg1aQhdOaN0llLKrtJF7X9+dFxaGOP0pinGvB64D68W057NIquco7iuJcqfnvdCiqgo59+H7N7L4Ss82aeo91sJuvmDYw4bOT9BJOoixAFeeLCER9PRMUpJdjZoAHUtAn6KY3pmABO8oyiL1dochCZ9VA= 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 CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Thu, 2 Mar 2017 11:38:52 +0000 From: Shijith Thotton To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Thu, 2 Mar 2017 17:02:24 +0530 Message-Id: <1488454371-3342-20-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> <1488454371-3342-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: BM1PR01CA0021.INDPRD01.PROD.OUTLOOK.COM (10.163.198.156) To CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) X-MS-Office365-Filtering-Correlation-Id: 6c4a0b57-29a7-4c6a-6edd-08d46160b523 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 3:yMPB+VFOoTHXc8kG/NP6KaIMHNtiCOoL0khd/rGqoqnSxKVqRWg5tLR206Pcu9GB0cIs09dcz8ehSTXpeX89JDkWy//CyQ6GAWbsQHGAeFIyVWhfsxOUQm6Y8vaJcaxvnigob7H+vbmwiSH2/PCYXrlK03sfiSdMUNCDuKEZOcznrvLhgloVDglQ9EPAvlvSSwb1Trj07voF11QDsyCD1Nx2cijIG4RRIwmOlc09fXgYnH7D6lwQtCydtqNb98qFpNTis9DxNn3bFh51PNbzEQ==; 25:a4fdol55q4u5f8H6DTXDlFjuuOyBagBWRPyHkQrO7NyL3qwoXa5J8wL4MTWYxmw6TX9gtw8fwvnAlPfZFhkJGCUpPoKEQlBDGfJwAE/TyHz7JwmVj78r3IrbXaE7Dr2O1XtPDDkFjFhUWwCueypGd+FdKRS+NYQdXOpg4nR8ANAlG1r+TSlnZDyei6CGcttlUoUUFhxWAUQotTVwH6yzwZXVOEr7K9ZGUHYKFuY5L0J7U/v3scyovpgq1rT3EQxgnronUJEy0x/0bjAYxPp2lsXYBE8OcLMtbAMEEWA1UIbwdCM/gNFvfcoi4eqtoc+oBdJA83QdC9fIsO5W9KGQFx1jRePqR5NtVkxmqIeQdYYT6MWwqbL22p1ZTqfGplKf6JCwU9ncreF0wEA+tjpZ9URzEX9pq/SUluK6iN0+Q7n41a+k7nShcDmIZcPicqNke3+hHNtB4BYa+CVNR4FDJg== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 31:sjFHBDpHrMFgPvhOcs1VlY8oRe5Mj0E9WDDz6Dv5hizY6yTa4ZXT72mgddo7liIoxvX7QuXgJpI5ciaYAsroE5/ftm1pGMBEIWo1mMos5+x8MfXpS28V4BmnPHuyZJYSgBIYF9qcIUzqpUOr3jy2Ux9CttOQBIsAqE9CigqHylrpw3zq4ETbBV4uftveqAPnXo/FksvOe+6tu6NE27nRXHyZEGQ5rmhmmNsDVIa7hgaYqdrAUcNrYo2nQqu59pMc; 20:C42PJoCTX9gC4JHrGr078ZR+hMDpM7b/73KKzh5KV/xz8ikfQtU6pQQvV5AIBfBD/yQ4+cNC63ix1e2qOsWSDLwm7CfplDnYHIJWDLEGh59C3VW2QrFqmAGxDcvp8tWYzVYV22AH6/thF/E0TUdKpwAY3u6V5admFAVedeoXFwNpGxD9+NP4N7Vr96leILteoUy3Qed7gpFLSXaT+BliONd+W0060/vk3lWsg4DCnOQKn/OdXc2ft72YQQRvivuA1tmNO/MDllDecf0hcSOSydM0/rDnADpCm/OwOXh2kjiFXRSlZjjkw7Y99Co79pkUvQOBXiDzK/pKY4R3zUa05xfcqb29KF1rrKYESNq+niAP4sKxgMik8jWlkiVqbEvnMbLtZcdCRGa2yCCiH7IMN9X0GqDp+8M8uaAbD69NIHVg2vl3ImwBhc5c3bDv+6VvPptuG73/xGEQcuISXHjvTelgPN5DJRxyL1RZU1qO+caO/tUB1Rw0XV43ZbLU3Z7zZhsKXlE8RYbNJteBex82bXl/etRsaOpJ3Gew0Al0hvrTSBdpJ9ts1MwOOelGo4i1m2WrbGNG8Lwh9xJcM16qfSVxq/itIxwbDP1mhW833SA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123558025)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(6072148); SRVR:CY1PR07MB2277; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 4:IGWgltuK8dP0aSdk8AGcX4iopOpeGo3ZmY8lOmpZ3h5y7/KM+GufdIjKr6HDWvxuGnU+tGaBlcE81ORXh5fQDAw5sYkbih7NemDk6kiowNHEZGLNsaBLA0VyTuMZrX04psvu/k1oOMsxyDq/O4NkunduajSEGpKczUhitFyPI7bPljNc3im7tI6sfeWgzPm7SIJ661DBKzu0z5iEQPjQ/LRNrwU891UAEDjLevbNuoLLkU5RmmdU7ILGPqkVjCLPz2eirzVQt1gCiLlLuFVlL+SaaqqNTXhlJhBgi7Kpl8FBCrQI5UNmFI2xZJFi5HZtT15WcESF4v6hu9CGn1HgLNDDdYnCOioz5aj/TkKYO3W35jOExnsVY2Ic2wnPPPUJ9lA58T0itUyoLLn4XMFmapOvEbk23vLVhxJ8xwVbJXpSw6Czwlv88lMpPgMQVzAEHc4lSqZ68YnAZ20wfgj4vtXd21UKmIlwXYsz82KhsCExyaG8SxuqCjMgrdATMV+3SanDnoNrkHeYECiOJkKnoXvmC71O7lsIj4ZLNiXcFD0z0hKHksP9TuvMJz2Q29gnlvLkhgo5wYY3zfbEhMpnSt581Ij0/468m/9BaLnzuh0= X-Forefront-PRVS: 023495660C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(2950100002)(6916009)(42882006)(575784001)(5660300001)(92566002)(4720700003)(33646002)(48376002)(50226002)(6666003)(2906002)(5003940100001)(36756003)(8676002)(50466002)(81166006)(110136004)(38730400002)(4326008)(305945005)(2361001)(53936002)(2351001)(25786008)(6512007)(189998001)(54906002)(47776003)(6506006)(6486002)(66066001)(6116002)(3846002)(50986999)(76176999)(5009440100003)(42186005)(7736002)(7099028)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2277; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2277; 23:X3NVMKtNGVhkDbzkiQp721xeR4XvgBKEMGePP6gli?= =?us-ascii?Q?ntnMAeO91A9lqyRvM57sLdVd6fjPTFwEwNg01EBK42wtL9Z+F6w4AAcpg9KG?= =?us-ascii?Q?y8dTNwkVirsv/k6kf+QYRlfd6Lc8SVZndL9QvOaop0NGrQcfj9dLm/zWLyWI?= =?us-ascii?Q?HXPwAy5NSldl9DODl/BSQu1C6/7xIMxBSSJGfZIB5nSUHNeQN4N+y7S9TrNf?= =?us-ascii?Q?cjOsJLYNyv1yYHBcciTIA0+rOvNc9NRfIdSWiFmrMVQx0frHoAJ13NalQw9I?= =?us-ascii?Q?KL7jOU5eQvewtVYHZHEmsxC4X7shSbuNSflBXwXiH2Mh1W09jGNegGiYTDXC?= =?us-ascii?Q?OtPyo5iav1ojW6iqjHHXgUOzxfeVMZ5b649hf/iHak9ZmTzItmqIne7GUid/?= =?us-ascii?Q?1Cgq8k/eZqVnlrHIpZQ6JWGvGNExgoqJ+RKgMH7ABX2NFZQdSzULHnTVNKHX?= =?us-ascii?Q?2ZcgfvfPcKNLylICTRhrz/6OIYkye8coccYT6N8pV6HAtEWbowhdeiijfdq5?= =?us-ascii?Q?KA2pPIVLpvZ4dr/ssC+RrMgIaYJXGcOiVZcBY/YAjIGDEry3kiz545kl+o9S?= =?us-ascii?Q?OUhdUKuafvVlDC66W2sValI/AWkX/5wd1R/7SA+mkkn7XO04S0cE8Otve7mE?= =?us-ascii?Q?XeHLXaAryenFNCy2dDeUkuvE8sBtzFFOoK2ZEzRjgzJJ0UX8+bR7JOchM9i+?= =?us-ascii?Q?XtzhW0ygFpf1I5cica8aehLRTKpcqQ/LeOorH115Rcjf1UCiIga+w/h5q/ih?= =?us-ascii?Q?wrkeCA6qttDpCq8RvXC1+GxpNjLoh4suAA+rV4anSOK7yefKg6ZokQJYQAp9?= =?us-ascii?Q?bZpqAanakt7HiI02yNeKpVB5F6GXM9Zvdhq3LSTGDUP0Qni3d/a++KLUZi5W?= =?us-ascii?Q?51Qlibglg5RcTICbR8GhrnoGeXIAAV/em4DkPalm7+dj7CBy6x2wQhi6d8Pn?= =?us-ascii?Q?URqS0PkrWtUQIK3kZB5ZHwnHdmy6pescgym3LSVXwOoaiKojmIOR2Ua1BTdf?= =?us-ascii?Q?FXRHbEs3QYTSl3jWsRWFVX+M28i8KgZtfNm1SEwD13FExC9mph7kSb1Vdm9p?= =?us-ascii?Q?FR9q8adkcr8CnoFPdxrwlldIU3khPIU86mDQqGzHkFzJUmM2DnbV0RoIry/b?= =?us-ascii?Q?ySnSGSqLAA=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 6:PCNDSa+KhYeVk/4Z1ZzUyKetm9MVYvBPwDCY97jZuuzvlBW/0TUKw2aWgqV+COfBnVqdcItGXl+ROkHYaKSBuAYIJ8BA09uIscr2n5pke1s+vX4zKqvrotWxZh1Da3a6TFduOK15RSghW3MgukNJvcAXnDgUtzhPwtoDLdevm7gRSM7oy1A/gx6q4pnW7oe7FLgd7r+IHW1ro1SJogKtSC7VOPcg/B7X+Br6vIE/p0OIF8IC94KpQViaA4A+HXNQLI1oo3hjErIuy6iOx/p7lMC4ox18bITvttqh2Wb2vtTw8+zU/FjflRBWr926zUZJDzIDU+MgPdYYdXrMcr2/nG+fLkUTODTEyd7q1lRFqU+9600bQniev5tklHtwI96YvaNNfwAHH2iQSetaLJSQRQ==; 5:DlCV+GVtdmk/CaYHkCfBNe1FDFNrXabaleWBHMVc8DnlpY7Ydm5wLvTTuFhtNRydyaQC8TLPCYsAUM3pWATXSdbU1zozUX8WsNNY9pzkwbkHy0516otyYCB759iZEccXbHXzhbOFyG9pnIan36CD+Q==; 24:sfAs7pZok0kPo58cgFgEIS1IeS5Pib8v2692FC7RhP0+W0P5beEvXVUGuYWWq/yBs1Ba3vOo1TW2DQhLlDTLcN+wrVqxOkjvq7MfKYah5TE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 7:nGaq27MuiMIVIV1CDCTwJdR/2WK5A+ptPgGaDdSTq0NdvhJbEly49lv3LccTEniXZ3kmItgspPr7mOvduMZw3cjPxOfmAbrvZG/U5ERgb76maasUoBraaybHWSSMKwYzwxCTZlNeP6vJDtx/pIO3S0Zy7Hg6OXKbpPrTsSGBka22bbL2qiUImYSxWidRt28MAStFdhv64nVmQma3BfFK2PWIHwqEsy68RfBr7gPWq9QQgLXg1Mxxk7OrP7pAbM5cscKPG1IVP/oXBvQEIhaUB11P1k57JV740CtZ8FFypfWo+LJ5f6B6wFIVQxkLDGmSDOO7f6XgT2RYWQqOQHXaOA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2017 11:38:52.1084 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2277 Subject: [dpdk-dev] [PATCH v2 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: Thu, 02 Mar 2017 11:38:56 -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