From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0064.outbound.protection.outlook.com [104.47.40.64]) by dpdk.org (Postfix) with ESMTP id D3879FA30 for ; Thu, 2 Mar 2017 12:38:52 +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=jghU+6XH3Ys9t4qA7FZfVMWFpyAhlOInV1AwjYyty0F2/2bNQXSBYrJXJuBJgprH0EGarXukHHsrdVl0DXvLdHykg8CFHdKE7pgKjVc6VSidNoHESmKwthmgl0t302zDAtlqMw1RdDYKj+UEpFabQKbkGWum/pJ49QqwgUPMaM8= 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:48 +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:23 +0530 Message-Id: <1488454371-3342-19-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: b23c8fb2-ca6f-463c-33bb-08d46160b325 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 3:rJkE76gJtrBnBmUjtLpLhcvmRzkYoQcx+penWycRvUQJ0Z68GemzYcByT8RHQ3uaR3zLHgqO23bfhStoWiHxWWp+Hf0xQWM+NP80CEyqUkjoLoNgVKH9Gj/FfrlANEnONCIrwhWAntGQZNGTHL4tRPVS8HNVXZoBI66kzW6C3VuWlY2dwmntLs3EBe1dl9rR9LyPp1TrypeTgzi9jiwXvE62DzieHuOmDbvpq4GLFRtONA9h7gYaiLmZNrkOZuxyxL/KXJJRLEovVMv9NQ6XWg==; 25:CkiJUhZqDrdIv97mSWQYq4/aDjwmIfh+zxihNDoc68n3urykui867ggDvRwDnx0WbeiWnKC5F4QNprij4hknQq+9oAHpRrgm0gwtOHq9xoLRrhh8CH9BLsVEgoF50ebmUxi8UG0nVlrGGK4X43+RIY7TvMqYpGsEAMRVpJP6Giv8q4HYQnf9cJfXfmuNwW9/IHpRPqvCfFR95q1vk9O+AqBZZ0+ipL6bR4MpfDJTcmgnGGG88P06Nb5SsT8yUlr9axM0+gAm+CBXp68A+1kyJpUo4OQF9bnrt39otOW1Tm84QGxKGjjf5UMiO3wLAdo7xWdBvV0oEJreILgNUu7mqDWFM1IRrRbILy0lHRzETpvHVW+3XdSRe3ZaJ0VDisUkpXmmgA74Mqe4UVNDwcEkjg81k7940jYaC2YPfxbDNby/AUW7mwJ3phKElr1at/fDlT7pM2Fe6k6zZrZ5XNwGRA== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 31:ZdxHY/efj/cvTSM6LFcHdvGxs80wnuE0HdSwNsEd6VIA2Kh2CdYkhrP6kp+5x5guKjkWqBx0GfJhtwD9hyyD79EYCPxNZGrVQmGdGdrLn/zW+BYirJiISlzktXrDUDfs7VvY5scFp5EzZpBy1/e46wkLw0VP4D+NDKe4HFO4DNxwYPzmWgjXaGJWMOWduKuDKhKCdCYj/CF5DZYopq/xhnra7kRy0GCBjksjsW8Da37S9Tg63qKOjxqZhCBsEio/; 20:vxT4pkJfpjoT/X+oOkt94PplcQcjUYfP6IklJ2zvt08wDf7kos++tTidxY+ipA3tLhDrpFcsq58yh0VEjpbOUjYNJU2eUMQ6KK8Z3pNXGJJq78kijuvZpyWFf3IUWyCM08ejzL7qhOjwbg/LEAUmMxCaE3IDGWEV6oX2A6tL4r38CZinLUGDYdCkzMMIHIC1xgnWWhY8wkIoDD85SQ702kxi5NRs25L0rBopBJhQQ+N5PaP8+3EGl/SuZI97QmietQrQmQHed46qPSs1EmF4IPIhzpnDD+fBKGWVJuEZOHn0YtJL3vshxRtQyhgS4Mn7dgjgIS2aqo4bz3ydfW1VY7kNntFPoGfAKbDg4SkGCOdYgQ9O1H/h+Jh8Uf44M/vnqi6ACpql5ouy9qJfxPQ70Hc/0J4NdfpGpscb7ycFKM92hyJwfEIIY0jR7+Q4Yy1H/rBKUZnfXQR8i7iX7NPgp9xxY0fxrFm0tHxmizbGS42XPS7ZtfAzl9gNRcUbfJ1MB6f1FpbKQSwiQ257cYx0Ek5RmUqGOVjR3G7cpBPU3L1vhoy2sCweErd73oOYTQQzu/fZQ4Oauhoh9+CqBS10ezHGwFNfaXWsK/ux/NtEL64= 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:EoyIeacfXgLJDA3WQZrz7o6V6PhVZ0JK/dU2lQKLukZi0YTlbvsecDjWAtmMCn8hSZYE2eBYuH9E9Dlw62rcHkp0fyt8MCSr42AL2DsasIjeuBOHGwssdGBIpowEmqQm+r2qrLh0exvAnmwG6wySHRsqoOsHrE4bwOygGq2H/33uK+IYYTwG/xqFqjcsEeyJRHFM4iBLU+LUskqbKBiTjTQKfEmwF68h9XXbu9aT0CvfZFIdCE+iLSDH88DoH3W1IJrlwrGS7sJG6VIrg/dsO0fajm+qYSOGr0kX3Opb8mao65Nn8c/nijcJnh5TO53K7a/oZOw1DHHSTD5JyIlyv5Ii6E3KrkL6gHUDNhlBmloMDDitKjAwk9kVggvECNayIMat4brAOU0QxkLU4BI9Bz40W+CoXPgkwy6pVh6zFDkTyH+Y6ffIS2v+waBL4i1hj1T8geyvfTPSxeoAogZM2jBub4hholA9DDf3C2PzFvHuxnKM6UDdDvbbL6C3paHEmBmhgx+s8Vq01uIkUX9mP1kSGYTNVIKY4VlOxosefJVTmTdPybevEIAGk8P5ziDYB+yqWo5C0y9X+SRjQp1q5NtKiNT8oW2o6GD4g5YDG4Y= 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:ucwUKkQvvHioSOApynhhJ2IAv/WQ00dn3SUQOrCKk?= =?us-ascii?Q?g8Fkav4AlnnYHV9utvCd3JuOUwbKNpdv1QcC7jKSfRYVY9OhaD6Qn7lqpYnY?= =?us-ascii?Q?Krz7TrM+km8GCOUSnDbi5G23ku7yZlM6nmc07FbhSGkhYMtfqBO8yJNoXvHs?= =?us-ascii?Q?BhVbQA4NQUvcLO9iXXUemAz+yWkA5p4+nCjEYpxNIqhCLc/Df9RexQoH6+cy?= =?us-ascii?Q?zPX5CJghc/6ST4sqIKGm45UbOIDn7T9+RXSCMTuUl+9ch/zOQYqyshPq8RP4?= =?us-ascii?Q?HKRpNNZi7HWxzTCxNyUWEA5xHlME406eCq+2PBjAJwYosZ1FWBdWl5Tbipjf?= =?us-ascii?Q?pPngP6y96u2E6BLFnDjBHxbQYlNsZsUAfyVW/9RnQ9aTFA2OFilFYMbM58Ut?= =?us-ascii?Q?/GWO4mqy9BX412sURyFbZOowmIhvo8Biq+FnX+zABUYZmJztg6L9m2DC23GX?= =?us-ascii?Q?/nmZ5HDSNIvw1Vzj1f0jisQwkdDrcytr+k47hNqnE2N5Aqfi497ZI+5Ee6rG?= =?us-ascii?Q?/X+wFFQfq34DTLWBIUYFJS0kVXQhZZhJ6xPD1tjACbj1hXkGmPm65WPrJVdu?= =?us-ascii?Q?drKw6aPxr/SUF2ArJ7hxqn6I2u0ssaZ4zbvDYAVSmmfzsZhgVmr0IETwYQuP?= =?us-ascii?Q?4yByf4YPJ1S4BJz2yoXlzljSOqTz5AC5XbV2vyxKttZY87390P/Bh4DOtRvN?= =?us-ascii?Q?2FNxu6xQyP0UF4WnESZ7f0pwvGJTLyGeDPIKT6xhDDHONqvnUFbFt769MLHL?= =?us-ascii?Q?kEDrZ/VnvoJMGaWFnVjBfPyIRF6r6S7DwQuxvSuLEyipUJ+yprNpiRvRgLxd?= =?us-ascii?Q?jIyCF4GDW/BukajRVlTsQ9FJamDZlpjaxHNIwfCZM0WCgcdbaHU8BHiVdE7f?= =?us-ascii?Q?Ta7MfNDIzABGpttH9fRm8KmO2nJn8ipPj3hgZYove9vei94BZzSxoJPm9WJX?= =?us-ascii?Q?Lf0AG70dQ8sMLVaxcdcGSMUwyFohxjRyaGP+Z2Lpp4/gbWcj9FyzCKADad0n?= =?us-ascii?Q?jrLYutjUSguvSpP17Yf1lukI3WYHcIxQPSnp5/Ts4KygjG0HvdyJUrNu7AqO?= =?us-ascii?Q?D38GdktrKJx9HSpMZRFJxITrIuSeAHGjCefoAfjHDS/o89JzhhU9Jkc1UUj/?= =?us-ascii?Q?2bxmVu5wfI=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 6:PGEMaAGZNK7VYdz/rP10MFyDsWcpqM9BhdO5RgZLa4zireJ1MlEpnTo5SlS9SEX4yN2+8Bui5p9IZ8UcDivhpC7g7RH/sR1G5aeFpTCbnbIr+bfHInxqv+EMDLK+NqwKcsrlLPWyUYTXmjKD56WxeCtfaL36jaLvxOyDAPClHqmitOHtFDldEFoFSkvC46cOuue+sC/+WG05zcLVPiS08FcFRyGgSRggYY1U5ESxolQRZzT7Sn+WMx1LGCeqcnwb6tzlFJUzRDchlVu3qVdsQfJzKZRnn/Z4Am5YwVncYCvCVzBycz1i6pZxEwfdxEOPw9da28uMtanxsizTiPPM1GGC/ab/KJbvX7GjN9hDOSWMUL4cqKA/gsCsd6J434teCt06TMfIIErZqIU44h7W8g==; 5:Dl1g3yiXs002FYLSo8QwSaJJYRm16yfoAYnEIUMpB0c1b271gEO0EF3d+KUJl1PpxEQm16NGKQ6WbHsu7McRTHRZWZcf4cbO8smQWAoU71VizB2e8xWnXeF9IGV5tAIOEcTTYV8cjZ7JuQRa+ct9/Q==; 24:GBbwUaN+ve9Z3FTJgelQo5ezgzXJeF0/DXYexgiPUMNRNr/2uNDkHkWNm5XogesE3v2miBkkLPfsRbPYTzGH7FFYTgMk2GirynzceZk3mDk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 7:tSijCorkvSE/4ICHgmsQJNqTRBGeqUE8IJerZIZKy+pyqwh49/zbGDG311mmraBcyLx4fK6iC3EAvxY4NRTp+hOpbyeKg4xhv57G6rZs+7yiIPPRLWYl0O/tHwln1e41ebpz8GnNrFmmKuhO+PzSWaR0MDwBIVm+fbsuut+KeuQ8mYxu9F71Zpw6zVFaUmxB7ebT5c9jvDfk09hJpUbcvrbmIcD4NV8AOViMFZfDe2xNHAwUuqCsNyHIbuiWBU0zJabV5LLPWGJmYYartezQ03s75jyNGuNA1mkvnU/4omxOfCV3QEWQNCqBAUz1GvigHFgpFhe1VCmIBf/cg36PYg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2017 11:38:48.9833 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2277 Subject: [dpdk-dev] [PATCH v2 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: Thu, 02 Mar 2017 11:38:53 -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