From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0080.outbound.protection.outlook.com [104.47.36.80]) by dpdk.org (Postfix) with ESMTP id 22B8ED45A for ; Sat, 25 Mar 2017 07:27:51 +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=60htBzIta913aBd4PjP9n5lbh00H9G/iFuXb7+88zxA=; b=aLVhc/hUlG6gFFG4mXa5NZUfAIVysfMY7Y/DFJryd02wkLJ6frcDi+XAm6u+omgaGxvpjpnLKugSndIBq668U4PjVYy3pOmDb8N6CNTS6nS6aRb+Q4fcg6S9c6sQO4MaucgN34gYuwiPunYMMaDCvIOQGOAUGiVMJybO3DAv5Zs= 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:47 +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:29 +0530 Message-Id: <1490423097-6797-19-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: f6829b99-16ce-4d0d-fdd6-08d473480f42 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 3:fsu5Z5Hy1UfZTIzm1oZghur7pnZR+T6JqsyOwePnKe7X4QmBeopNpkdmA1dmuSrhcgyaA2kg7XsaFbxOBYuJa0LIP05GfpiSM2PEtgeEzBG7DN2KliEk23QfbiYXLt2yIvCv9EI7KCblYdXSFSZ1iNQTYr7xEphi/x7fXmHlhnvLUswTiAKA3cP6CqMjAw0Nhjk7N4kY/akbUP3C0VKXHe4YX01e6MgfGgT/3J/fR+C1IfJUx9wZSxfIy6DlUqSYNr4fTRKGSv0f7F8av4B4yg==; 25:Ogvn2DQe3nK/vwSchgL03COoPMFTV713JtSfGqv8grXL/S3mJRhE0oZeRy4YbOpjtPbSm7pDhRYhCtsr/kHK9wB+sVHdSzevScdlJYXOflYTeHNLRmpannxHJyfTQuGeFBle8K0hsT1P5TgFfOg1joOsxHmRqS/d7CHtc9xYSxtLJJXBkF6f0jQjwOSm4uBSlYehUoUAOJZgilbth1FQKPYRPXygY+eotfD8d53uCHo025BrJsJMgcl0KmgZUEYXzOHqMaLEBqIRepPQ7HdMcJaWc5RVKHKUuTm3tk8gF1FnHgBnpOAI1izzmFRLrvMYdNTKj9sYEGjZDeCp0op0ZId7KFws/5h9r8ttscf6QdMqkyzO+2nDJhlLoBZAeB/xuZeq0/zNzdjyTioxsNk3V9dPdIs6XNkgVc1axKWvXkYWLth9wnzHsJ5aDmHwS17p3y2GbgzqCor06j5eHaS38g== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 31:KH/mO44P1VjVNZrB2o8pj1wuNZGh5WCutRXAcEisnj2Vuwg1xi90FwdByClNkwqs1caLuSNaMiqRBRzp0J8Col/t/vU7kZoKD76NQFp4rv7INN+C9QMYUiWqn87FL8Z06WJJsnB74Cplws5qn5hakhdzfI6o8rQpiflV5DJ2HaEOrxoFjgYrt33uezajBxN0+22YwsxSCA5neVa0V7vIl8kx9noDxmkzK/3r8D+H8KU=; 20:Sv27IL1iEAqqeyZmpN81djNLegceKBr2iN+//OzpoYNMfPJkLLlFGRrbDqODbWzdFkNsIOZhcuyhdYyPhvZYwebRuFNjheH3vrmivg43rZJVGrGg6aqlYB0v+aq3GDT3Zq5imCig3T9NsHzlYsswYP0Z50m1UbgiG+EFEzEEitOxm9qClDSNEQB7iDq0dXO8l6ySH6U790ZZExHcP0iNCiceKGTzB8aml1zpJPp6SsmIz9vnSARwrUNBv8BjqCUGByu2bGDbd/JCKIo7brF64wMIblFGXfl0PL45Z9i7n/wBJgmUAQ5ElNl/WoJS2sgfdEIZOoMJlxyffzB2tCuQUxDqlOjbczPsbtRpu2zhorkqEcCr28i2RwwwI5bVsBtcEALkW58yhCWI5llPxGFWsFaE4HCZfLLzmuoX9A7aNVcgSnRdx0Njska/RJdCifRIC2qjJdwCZUpcrzBhNZRWSWnHR3Y71WmWjjDlwo3T7C3aOSz/HDqlkIPC9Vc/nZ3DzBfo2+1jDPMl2tiI1KR2nYvpIGbOXhznmNX6bA3swMoAqqMKPaCcBrWXXMRdcj8dW//ZSLqQWUnXidpYtSDh7gjYgxIbih6VmUe6SiqrAtQ= 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:rtx4Uh4skqbLX2Ss5YVzcNKzZ7lVdNXQzX0bBDFNcd8scO+ohtoi+37nCh6d6kWacPLIOcn8iQg3SHPN0+EIy/J5/KBbijeXyDBgFpdgqrhfogCnb6NpxiK50+8T1Dbt1c8CweiiKCiZv4rVG8VGWJgLqLbjltLmAiTtEFCsnGIqEw6lQ90t3uIS41aU5FFE48NsWJ731SNc+OiesKOtGBEG/5YqiB1RyafHPk6GtewmA0q7tBqWWO765HmDuokxTxH1IlDTD46YDIu+ZgPgobWXu0YoqzAoFceiY5WBiOxbhnekRAvzIwN7OQFmo4ykt0lZUFSBi9V1Jh7M/RksHmy7QkxDRh0EeNsD4IW9A8jhCmkLsYNE6aGrmguqAAMcS7Ji9YgaRYYIYnGvS9uOOMeTZrR2bOWCKYyDs9QSaonkeJ8bYhMBJCZYOJ5u3GzU4LjCPZ83N5hSVUB9lMudPGaRMIrvln1mERsbM9C9aSWdvL+29olb+7/JoQZxb/Zgmh7kf4v8sRfbtpTpojE6cJlT6rAREYGVf4cpi/AFtmNgEq6RHfuAimUZJQxGwKiti33gJrvzcUaYQh7qt9LB6o2RFpxoAQLsPfrvy6KzxJ4= 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:Te13mex/9gyxbFmN4NNWQve9EiuabmH9/HkQFRQO/?= =?us-ascii?Q?hWr4fHZF2YzqMD647v3sVXM1tHwl0sj3cGRgh/H57yli9WLTOn9wUkNVnsxF?= =?us-ascii?Q?vM+W96yo3piRiwiitesIGm1OgFvo/vNBMHjbvyZx0SEnABYL7j+5aG3FINgc?= =?us-ascii?Q?bR7/Ts5gVBtQghpG9xetlHWz2CkUc7/gtvInlgjlkDuxRESm4sYYJ9J2RHJB?= =?us-ascii?Q?vaQkdhcNQKsEaN8rJ/BGlhh9NLIKyXKD4rI2Dc5rE0lZq8lhxVxIgWNLkp2Z?= =?us-ascii?Q?cPV4RHVlIODDQn7nRX+Soo4WsWo4J9dV52N3tojG7nCXQzwtAwg0I4wk+M8E?= =?us-ascii?Q?8BWHJe78gibx9zQN7w0X2NAZ/IUbU8NceLA7l6NHy0zA4UwCfEY0fcLUP7OH?= =?us-ascii?Q?2/mJSTPjHJ9v/P0JPbBg+ejo0F3zpCKbqOD9iLGWOkX+z9FZdgj5o5k95aaH?= =?us-ascii?Q?p365+d2FwsnZaTZhTd3oabfgcRCGF6Rp6KjL+CKOHcW7XfTSjOVnbnS0OS3J?= =?us-ascii?Q?Et5y56wLG/psfJYcMkBLx+SFdbb5SAJfJGFrrfSUbAq29bgYgb+iUO8a3dZ/?= =?us-ascii?Q?z03ttiK5O1GvT/uvQrEFKq5xvhVaTSLdsKMhkGhJtye8oUAfGnlOZSyq3f9c?= =?us-ascii?Q?aeOgojs14Gh50FRLnE+ZMK0Wree1bvCq17oNrXO7T9AlEyCxEnSOzxZ+JdRh?= =?us-ascii?Q?rw9bgDg1Szeik/pkvOdy48PCJ7bdHmF93SFKCj/lqsJ5SzNqiPJdhdf0iEEO?= =?us-ascii?Q?1kJGC3tdc/HYhWfENA855eI/0uBO0+0epNbTGgBALjDgZPBYsERZdqchUOpX?= =?us-ascii?Q?ZCUGtq6Z72I4oaSU8Ft9gBN2xiv2cmJRn47R7sJ4jD6ia2mXqea/Op89koci?= =?us-ascii?Q?dwEthIOa+TWZTCdwXNpzDk6SsZ+vcNxXG4YMSG2seYMlHvOyPrUX87KdRGmA?= =?us-ascii?Q?xKVG6kg8X50wBiu4+FEaiqfKfunCwuSsl53gW3HZVwQdvReeGmo04niKU7BE?= =?us-ascii?Q?bhz1XwzumCvj4Hf79p/2NgqflJjS1KOdE8tNbTMtlBl5f52/lXP2iVhWDM5N?= =?us-ascii?Q?/RF5EjwBfh4g0q2DKObIbvebbjEwv5ekeprJbJtKG9VqC1T9Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 6:Wm5JYO4E8kxD8FCVF1VCbWTmC3Iw77v6g9SYOR70bHrwrwBzM1oxdoOdql7zKUUM3bmtD3nluM35d9l+oUi/JVDa1Cit6JqHYm1D+5hTIpW1RnlJfuxyG3LkPCCRrfTx8l9hghHT44hjlk0EHO+onrxk/477UHhD/ojRNIkmi9uxxN+ln7rMjBkCZpbojehJAkCndFYJ5hyzbB0noDvOS46xcbtcIGZLrodkhz8pQeBTilbXVGyPF8g2E+F1ftpJCq4zKIGhtjf6XerE97+K8fQtnCRaL8nIhSFQQOsSEkd2oL2mr4r8KnNoHpyYtrdfqx7X1fQUt1JqO7nXlPQfJkzVOVDkfW+CHgJP2FRyuc2m6ySKkHs+MuuSRBZF8NCYbxyXzk7qLHUJT0aIKI8Bzg==; 5:Ccn4q9XW5jGZ4meXEn/vuwONJTJVL9hAoDpAgk2jSzdWMEAeDLOsCjUW3goF6ZtN2BxQibkqBfy3tBU/nEiIvPLAdMmPHO2OdifxLOrBm0UUw9ncPuhnD3AptzU2oUCmJV77ljQHCT9W9ePM24bqew==; 24:ya4T8bZx7UD67y1U+ncDMl/6MiGEbAmSLforT0biBxvFW3PTWWtsUv6+LZjfydauSLGUDOB2Cmi25+9MyJX9kOPjUDXI9iA0PANsiT/BtFc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 7:/xF99NlMZ9jsMQeQwFzIJmeeQjkZ4HnDrSUnsBBBT60SBt5YYwel3fUZzjbfjt2oH4rzczIcfL8wd6AvfyPqV/51NeSJS/wYxPUaLtvC6WRIUnyvcFpde6LVP9+SeWtRTmIFxeiEYZjzU8vL1E8tfXpmef86m1Ku6FBUVpncKMCkQk9iYpmZuXFXd/xN5uYbnIcZnF1Fc/9b4IunN0SK1rWXwy3GU4kElOHZ2bEAe27nZERm46zhP/PVB6KVsaKO6tvHMVs+vqchDTLe1MTHSJHsvsD9P1jd0Vb5rBT3/idnsFpKqujwaDNHsXL4Hm8Bhdq5fjUYv51e+TuciRumqQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2017 06:27:47.2921 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2280 Subject: [dpdk-dev] [PATCH v3 18/46] net/liquidio: add API to send packet to 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:51 -0000 Add API to send control and data packets to device. Request list keeps track of host buffers to be freed till it reaches device. 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 | 11 ++ drivers/net/liquidio/lio_rxtx.c | 180 ++++++++++++++++++++ drivers/net/liquidio/lio_rxtx.h | 291 ++++++++++++++++++++++++++++++++ drivers/net/liquidio/lio_struct.h | 6 + 4 files changed, 488 insertions(+) diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h index 726ce6b..dc11406 100644 --- a/drivers/net/liquidio/base/lio_hw_defs.h +++ b/drivers/net/liquidio/base/lio_hw_defs.h @@ -76,6 +76,8 @@ enum lio_card_type { #define LIO_23XX_NAME "23xx" +#define LIO_DEV_RUNNING 0xc + #define LIO_NUM_DEF_TX_DESCS_CFG(cfg) \ ((cfg)->default_config->num_def_tx_descs) @@ -93,6 +95,15 @@ enum lio_card_type { #define LIO_BASE_MINOR_VERSION 5 #define LIO_BASE_MICRO_VERSION 1 +/** Tag types used by Octeon cores in its work. */ +enum octeon_tag_type { + OCTEON_ORDERED_TAG = 0, + OCTEON_ATOMIC_TAG = 1, +}; + +/* pre-defined host->NIC tag values */ +#define LIO_CONTROL (0x11111110) + /* 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_rxtx.c b/drivers/net/liquidio/lio_rxtx.c index c61397f..7e2202c 100644 --- a/drivers/net/liquidio/lio_rxtx.c +++ b/drivers/net/liquidio/lio_rxtx.c @@ -207,6 +207,186 @@ lio_dev->num_iqs--; } +static inline void +lio_ring_doorbell(struct lio_device *lio_dev, + struct lio_instr_queue *iq) +{ + if (rte_atomic64_read(&lio_dev->status) == LIO_DEV_RUNNING) { + rte_write32(iq->fill_cnt, iq->doorbell_reg); + /* make sure doorbell write goes through */ + rte_wmb(); + iq->fill_cnt = 0; + } +} + +static inline void +copy_cmd_into_iq(struct lio_instr_queue *iq, uint8_t *cmd) +{ + uint8_t *iqptr, cmdsize; + + cmdsize = ((iq->iqcmd_64B) ? 64 : 32); + iqptr = iq->base_addr + (cmdsize * iq->host_write_index); + + rte_memcpy(iqptr, cmd, cmdsize); +} + +static inline struct lio_iq_post_status +post_command2(struct lio_instr_queue *iq, uint8_t *cmd) +{ + struct lio_iq_post_status st; + + st.status = LIO_IQ_SEND_OK; + + /* This ensures that the read index does not wrap around to the same + * position if queue gets full before Octeon could fetch any instr. + */ + if (rte_atomic64_read(&iq->instr_pending) >= + (int32_t)(iq->max_count - 1)) { + st.status = LIO_IQ_SEND_FAILED; + st.index = -1; + return st; + } + + if (rte_atomic64_read(&iq->instr_pending) >= + (int32_t)(iq->max_count - 2)) + st.status = LIO_IQ_SEND_STOP; + + copy_cmd_into_iq(iq, cmd); + + /* "index" is returned, host_write_index is modified. */ + st.index = iq->host_write_index; + iq->host_write_index = lio_incr_index(iq->host_write_index, 1, + iq->max_count); + iq->fill_cnt++; + + /* Flush the command into memory. We need to be sure the data is in + * memory before indicating that the instruction is pending. + */ + rte_wmb(); + + rte_atomic64_inc(&iq->instr_pending); + + return st; +} + +static inline void +lio_add_to_request_list(struct lio_instr_queue *iq, + int idx, void *buf, int reqtype) +{ + iq->request_list[idx].buf = buf; + iq->request_list[idx].reqtype = reqtype; +} + +static int +lio_send_command(struct lio_device *lio_dev, uint32_t iq_no, void *cmd, + void *buf, uint32_t datasize __rte_unused, uint32_t reqtype) +{ + struct lio_instr_queue *iq = lio_dev->instr_queue[iq_no]; + struct lio_iq_post_status st; + + rte_spinlock_lock(&iq->post_lock); + + st = post_command2(iq, cmd); + + if (st.status != LIO_IQ_SEND_FAILED) { + lio_add_to_request_list(iq, st.index, buf, reqtype); + lio_ring_doorbell(lio_dev, iq); + } + + rte_spinlock_unlock(&iq->post_lock); + + return st.status; +} + +void +lio_prepare_soft_command(struct lio_device *lio_dev, + struct lio_soft_command *sc, uint8_t opcode, + uint8_t subcode, uint32_t irh_ossp, uint64_t ossp0, + uint64_t ossp1) +{ + struct octeon_instr_pki_ih3 *pki_ih3; + struct octeon_instr_ih3 *ih3; + struct octeon_instr_irh *irh; + struct octeon_instr_rdp *rdp; + + RTE_ASSERT(opcode <= 15); + RTE_ASSERT(subcode <= 127); + + ih3 = (struct octeon_instr_ih3 *)&sc->cmd.cmd3.ih3; + + ih3->pkind = lio_dev->instr_queue[sc->iq_no]->txpciq.s.pkind; + + pki_ih3 = (struct octeon_instr_pki_ih3 *)&sc->cmd.cmd3.pki_ih3; + + pki_ih3->w = 1; + pki_ih3->raw = 1; + pki_ih3->utag = 1; + pki_ih3->uqpg = lio_dev->instr_queue[sc->iq_no]->txpciq.s.use_qpg; + pki_ih3->utt = 1; + + pki_ih3->tag = LIO_CONTROL; + pki_ih3->tagtype = OCTEON_ATOMIC_TAG; + pki_ih3->qpg = lio_dev->instr_queue[sc->iq_no]->txpciq.s.qpg; + pki_ih3->pm = 0x7; + pki_ih3->sl = 8; + + if (sc->datasize) + ih3->dlengsz = sc->datasize; + + irh = (struct octeon_instr_irh *)&sc->cmd.cmd3.irh; + irh->opcode = opcode; + irh->subcode = subcode; + + /* opcode/subcode specific parameters (ossp) */ + irh->ossp = irh_ossp; + sc->cmd.cmd3.ossp[0] = ossp0; + sc->cmd.cmd3.ossp[1] = ossp1; + + if (sc->rdatasize) { + rdp = (struct octeon_instr_rdp *)&sc->cmd.cmd3.rdp; + rdp->pcie_port = lio_dev->pcie_port; + rdp->rlen = sc->rdatasize; + irh->rflag = 1; + /* PKI IH3 */ + ih3->fsz = OCTEON_SOFT_CMD_RESP_IH3; + } else { + irh->rflag = 0; + /* PKI IH3 */ + ih3->fsz = OCTEON_PCI_CMD_O3; + } +} + +int +lio_send_soft_command(struct lio_device *lio_dev, + struct lio_soft_command *sc) +{ + struct octeon_instr_ih3 *ih3; + struct octeon_instr_irh *irh; + uint32_t len = 0; + + ih3 = (struct octeon_instr_ih3 *)&sc->cmd.cmd3.ih3; + if (ih3->dlengsz) { + RTE_ASSERT(sc->dmadptr); + sc->cmd.cmd3.dptr = sc->dmadptr; + } + + irh = (struct octeon_instr_irh *)&sc->cmd.cmd3.irh; + if (irh->rflag) { + RTE_ASSERT(sc->dmarptr); + RTE_ASSERT(sc->status_word != NULL); + *sc->status_word = LIO_COMPLETION_WORD_INIT; + sc->cmd.cmd3.rptr = sc->dmarptr; + } + + len = (uint32_t)ih3->dlengsz; + + if (sc->wait_time) + sc->timeout = lio_uptime + sc->wait_time; + + return lio_send_command(lio_dev, sc->iq_no, &sc->cmd, sc, len, + LIO_REQTYPE_SOFT_COMMAND); +} + int lio_setup_sc_buffer_pool(struct lio_device *lio_dev) { diff --git a/drivers/net/liquidio/lio_rxtx.h b/drivers/net/liquidio/lio_rxtx.h index 0e7eb6a..9e2d967 100644 --- a/drivers/net/liquidio/lio_rxtx.h +++ b/drivers/net/liquidio/lio_rxtx.h @@ -50,11 +50,53 @@ #define lio_uptime \ (size_t)(rte_get_timer_cycles() / rte_get_timer_hz()) +#define LIO_IQ_SEND_OK 0 +#define LIO_IQ_SEND_STOP 1 +#define LIO_IQ_SEND_FAILED -1 + +/* conditions */ +#define LIO_REQTYPE_NONE 0 +#define LIO_REQTYPE_NORESP_NET 1 +#define LIO_REQTYPE_NORESP_NET_SG 2 +#define LIO_REQTYPE_SOFT_COMMAND 3 + struct lio_request_list { uint32_t reqtype; void *buf; }; +/*---------------------- INSTRUCTION FORMAT ----------------------------*/ + +struct lio_instr3_64B { + /** Pointer where the input data is available. */ + uint64_t dptr; + + /** Instruction Header. */ + uint64_t ih3; + + /** Instruction Header. */ + uint64_t pki_ih3; + + /** Input Request Header. */ + uint64_t irh; + + /** opcode/subcode specific parameters */ + uint64_t ossp[2]; + + /** Return Data Parameters */ + uint64_t rdp; + + /** Pointer where the response for a RAW mode packet will be written + * by Octeon. + */ + uint64_t rptr; + +}; + +union lio_instr_64B { + struct lio_instr3_64B cmd3; +}; + /** The size of each buffer in soft command buffer pool */ #define LIO_SOFT_COMMAND_BUFFER_SIZE 1536 @@ -67,6 +109,9 @@ struct lio_soft_command { uint64_t dma_addr; uint32_t size; + /** Command and return status */ + union lio_instr_64B cmd; + #define LIO_COMPLETION_WORD_INIT 0xffffffffffffffffULL uint64_t *status_word; @@ -93,6 +138,230 @@ struct lio_soft_command { struct rte_mbuf *mbuf; }; +struct lio_iq_post_status { + int status; + int index; +}; + +/* wqe + * --------------- 0 + * | wqe word0-3 | + * --------------- 32 + * | PCI IH | + * --------------- 40 + * | RPTR | + * --------------- 48 + * | PCI IRH | + * --------------- 56 + * | OCTEON_CMD | + * --------------- 64 + * | Addtl 8-BData | + * | | + * --------------- + */ + +union octeon_cmd { + uint64_t cmd64; + + struct { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint64_t cmd : 5; + + uint64_t more : 6; /* How many udd words follow the command */ + + uint64_t reserved : 29; + + uint64_t param1 : 16; + + uint64_t param2 : 8; + +#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + + uint64_t param2 : 8; + + uint64_t param1 : 16; + + uint64_t reserved : 29; + + uint64_t more : 6; + + uint64_t cmd : 5; + +#endif + } s; +}; + +#define OCTEON_CMD_SIZE (sizeof(union octeon_cmd)) + +/* Instruction Header */ +struct octeon_instr_ih3 { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + + /** Reserved3 */ + uint64_t reserved3 : 1; + + /** Gather indicator 1=gather*/ + uint64_t gather : 1; + + /** Data length OR no. of entries in gather list */ + uint64_t dlengsz : 14; + + /** Front Data size */ + uint64_t fsz : 6; + + /** Reserved2 */ + uint64_t reserved2 : 4; + + /** PKI port kind - PKIND */ + uint64_t pkind : 6; + + /** Reserved1 */ + uint64_t reserved1 : 32; + +#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + /** Reserved1 */ + uint64_t reserved1 : 32; + + /** PKI port kind - PKIND */ + uint64_t pkind : 6; + + /** Reserved2 */ + uint64_t reserved2 : 4; + + /** Front Data size */ + uint64_t fsz : 6; + + /** Data length OR no. of entries in gather list */ + uint64_t dlengsz : 14; + + /** Gather indicator 1=gather*/ + uint64_t gather : 1; + + /** Reserved3 */ + uint64_t reserved3 : 1; + +#endif +}; + +/* PKI Instruction Header(PKI IH) */ +struct octeon_instr_pki_ih3 { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + + /** Wider bit */ + uint64_t w : 1; + + /** Raw mode indicator 1 = RAW */ + uint64_t raw : 1; + + /** Use Tag */ + uint64_t utag : 1; + + /** Use QPG */ + uint64_t uqpg : 1; + + /** Reserved2 */ + uint64_t reserved2 : 1; + + /** Parse Mode */ + uint64_t pm : 3; + + /** Skip Length */ + uint64_t sl : 8; + + /** Use Tag Type */ + uint64_t utt : 1; + + /** Tag type */ + uint64_t tagtype : 2; + + /** Reserved1 */ + uint64_t reserved1 : 2; + + /** QPG Value */ + uint64_t qpg : 11; + + /** Tag Value */ + uint64_t tag : 32; + +#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + + /** Tag Value */ + uint64_t tag : 32; + + /** QPG Value */ + uint64_t qpg : 11; + + /** Reserved1 */ + uint64_t reserved1 : 2; + + /** Tag type */ + uint64_t tagtype : 2; + + /** Use Tag Type */ + uint64_t utt : 1; + + /** Skip Length */ + uint64_t sl : 8; + + /** Parse Mode */ + uint64_t pm : 3; + + /** Reserved2 */ + uint64_t reserved2 : 1; + + /** Use QPG */ + uint64_t uqpg : 1; + + /** Use Tag */ + uint64_t utag : 1; + + /** Raw mode indicator 1 = RAW */ + uint64_t raw : 1; + + /** Wider bit */ + uint64_t w : 1; +#endif +}; + +/** Input Request Header */ +struct octeon_instr_irh { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint64_t opcode : 4; + uint64_t rflag : 1; + uint64_t subcode : 7; + uint64_t vlan : 12; + uint64_t priority : 3; + uint64_t reserved : 5; + uint64_t ossp : 32; /* opcode/subcode specific parameters */ +#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + uint64_t ossp : 32; /* opcode/subcode specific parameters */ + uint64_t reserved : 5; + uint64_t priority : 3; + uint64_t vlan : 12; + uint64_t subcode : 7; + uint64_t rflag : 1; + uint64_t opcode : 4; +#endif +}; + +/* pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */ +#define OCTEON_SOFT_CMD_RESP_IH3 (40 + 8) +/* pki_h3 + irh + ossp[0] + ossp[1] = 32 bytes */ +#define OCTEON_PCI_CMD_O3 (24 + 8) + +/** Return Data Parameters */ +struct octeon_instr_rdp { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint64_t reserved : 49; + uint64_t pcie_port : 3; + uint64_t rlen : 12; +#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + uint64_t rlen : 12; + uint64_t pcie_port : 3; + uint64_t reserved : 49; +#endif +}; + int lio_setup_sc_buffer_pool(struct lio_device *lio_dev); void lio_free_sc_buffer_pool(struct lio_device *lio_dev); @@ -100,6 +369,13 @@ struct lio_soft_command * lio_alloc_soft_command(struct lio_device *lio_dev, uint32_t datasize, uint32_t rdatasize, uint32_t ctxsize); +void lio_prepare_soft_command(struct lio_device *lio_dev, + struct lio_soft_command *sc, + uint8_t opcode, uint8_t subcode, + uint32_t irh_ossp, uint64_t ossp0, + uint64_t ossp1); +int lio_send_soft_command(struct lio_device *lio_dev, + struct lio_soft_command *sc); void lio_free_soft_command(struct lio_soft_command *sc); /** Maximum ordered requests to process in every invocation of @@ -167,6 +443,21 @@ enum { } } +/* Macro to increment index. + * Index is incremented by count; if the sum exceeds + * max, index is wrapped-around to the start. + */ +static inline uint32_t +lio_incr_index(uint32_t index, uint32_t count, uint32_t max) +{ + if ((index + count) >= max) + index = index + count - max; + else + index += count; + + return index; +} + /** Setup instruction queue zero for the device * @param lio_dev which lio device to setup * diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h index add0e7d..f16571b 100644 --- a/drivers/net/liquidio/lio_struct.h +++ b/drivers/net/liquidio/lio_struct.h @@ -288,6 +288,12 @@ struct lio_device { uint16_t pf_num; uint16_t vf_num; + /** This device's PCIe port used for traffic. */ + uint16_t pcie_port; + + /** The state of this device */ + rte_atomic64_t status; + uint8_t *hw_addr; struct lio_fn_list fn_list; -- 1.8.3.1