From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 40C87425C9; Mon, 18 Sep 2023 04:47:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AC02C40DFD; Mon, 18 Sep 2023 04:47:25 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2112.outbound.protection.outlook.com [40.107.244.112]) by mails.dpdk.org (Postfix) with ESMTP id B2A2C40A71 for ; Mon, 18 Sep 2023 04:47:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b7bsrzBttxjKHdKrqdXSVHh1fRL2lf2/80Ss57vFfwLY6r/60rlh0DPxHWuRrCUr0noRvhVQc3jiY+hrC/U0weyRf3NcT/f+XqcEjSGUA+HkHRcSqIetHKfLHB5PL5mGDpcS1vfR1pDX7nMKGBBpoZXzBhTKu1GAz/tnPEdL0caPWl3R4k0exCdxfaz/rTElnU20pZ4mKKpFP3pIuAtp9rxNr3GyshfYGxT8VHIkt3wt0uFmR3uLarkwSgrpB5+yIty5U53aRJG5COvNYFTo0r75/6zFeW5/ddxu09yd8r/pr6GDO8usvYXjwAlNEx0VZvceLRG3QluywD1tATgVoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xU9szdiJqoW0Vk3yHi7NDtw9JFvSB81vHRSnHA1159A=; b=RKhYVetkreAjSKGt4H7TttUyI98uC48uymev/fj8Sh8ThK0FqgumtQl7BTVm6XHSkT9HwxKD8Q1iyUxGbfGxmahpkI/8fG5GORzomKNVkZLwkKoSbxdWe1xI9hSfPf4AY8l551yA0hAkw2kTCwPQEiYeTlyV2zsCakbF/BCYXJz94M+mV3QSnHKJRqs2Gjx1uVfvq/tIDKMV4LKPtfkXRHrKrEG4uyoyEmNFyFstcJO57oluAedLu5zQmGYG1W1Jiii6e1bNSLaK7JnprPwiPkVUJG7f92IEkLstGps8MxCWCivegnr8EQx9u9PIbpMCe9q4SCiOeYX3yFpAxU6H6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xU9szdiJqoW0Vk3yHi7NDtw9JFvSB81vHRSnHA1159A=; b=L8CD2vKzAkHFXH3AkyfnbLIkx3tDTAIqcxpejJZ6PFIThn+kOBvp5oO5+CgvTdgiupsu8R4otBqy6QF3cmsUpYhUbqS3/XjK7oBYx0OlrI0zRIPzEcumn5AUZTEZhNJ5/4FBBTN4Q56dTTmHXHOr0y0amzNcMQSxIQ2R4K2HFp0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by PH7PR13MB6435.namprd13.prod.outlook.com (2603:10b6:510:2ea::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 02:47:19 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7a1c:2887:348a:84bd]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7a1c:2887:348a:84bd%6]) with mapi id 15.20.6792.026; Mon, 18 Sep 2023 02:47:19 +0000 From: Chaoyong He To: dev@dpdk.org Cc: Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH v4 04/26] net/nfp: remove the unneeded logic Date: Mon, 18 Sep 2023 10:45:50 +0800 Message-Id: <20230918024612.1600536-5-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230918024612.1600536-1-chaoyong.he@corigine.com> References: <20230915091551.1459606-1-chaoyong.he@corigine.com> <20230918024612.1600536-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SE2P216CA0016.KORP216.PROD.OUTLOOK.COM (2603:1096:101:114::20) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB6435:EE_ X-MS-Office365-Filtering-Correlation-Id: 04c883be-7bbd-4eb0-c742-08dbb7f1939f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6XtFg40vpnSrgt12w+gbVHEf8tcOMwjl0zlom9aEGVy4lL4f/6najU1PMd9En/S1heZr+xGVWUQBFIRyPwh2uD5AScrRsPR6NM8IhpVvCor7A6/DOYD+PK1D2cJZW4MuNJJwjSFRg2mGuiangNpAoXQFqrcnvB+Hrnn5jySq/RpSXrW7Jfj1MS/41G8TUpMAcLxSjjCtcQHHKX/okGj1LuoErQ1XpDZjH1FORpVBfNKrJv3tANh00vWnIGF3KhXetukZu+D1+nDQF7XYmq/mCAICky2YEuzbzrtM0lGfThyhEQBDxoyr/oSeItHcgbRXD+dprNsUrLxaLTD1Y67TnZj3WNwaGk8dTVc9wR/n4kZCFyf6AncUU52aApKllDUJ7GQ/aDhgTVVhZV1/OFijZqulz+9I6WLeuSyl2eTlPbM8qNsry1/h+f7bCzQGrBtH/H9pADjNPYK8l5/UWUHCOVVAm3c2gfmuaymWyYI+V09L8XYdJPJb6uRGb5pIH5gtxh/9JtNg97IhjTeRH3cXBSPSHQIB6DySu/Kdosv1YFjlfDQzVD8x2fLQMR2eulJOhp5VItxsrKMwamicRAG1F7x0h5S0TxGeC2XwEIuqcfZdSSvoAcnAzPnnajSbs/UBfEh3YI3bn45hSAnYD8jGivlBsaYrx462OtvwjK9Bka4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39830400003)(136003)(346002)(366004)(376002)(396003)(1800799009)(451199024)(186009)(54906003)(66476007)(66946007)(66574015)(41300700001)(6916009)(316002)(8676002)(4326008)(8936002)(52116002)(6506007)(6486002)(6512007)(478600001)(6666004)(83380400001)(26005)(1076003)(2616005)(107886003)(86362001)(2906002)(30864003)(44832011)(38100700002)(38350700002)(5660300002)(36756003)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?a2RNMG5SdTd1TlNSR3hvSHp1U2tnejRXUEh6Uzc3ZkNvZERHY3kvL0lZbjdR?= =?utf-8?B?QTJBalZVSWI3Tk5iRCtMQkZTeHlQd1orUlNETFJrdmVLZ1JmbFJaUjV2N0pU?= =?utf-8?B?TDA0bmZNQm9CcjBKZ2N6a29vVEQ1ajVTa3RTNHJmeHhXOXZTVHN0bUl3TEFZ?= =?utf-8?B?ZGYrMXhFczg4aTdwa1ZWM2hFUnI1QWFSSkxwVlJaRGdLZi9IV2oxVXRzUnR1?= =?utf-8?B?Z09hWFBPYU02Q0pJaVc1U09CZ0g1VFVLWXJhTW4zZDJrNGU3MDZRMXorTXpi?= =?utf-8?B?bDdUd2pKQUlJS3hXeFdnKzRjdHpwY0RYY2kxNEhwc0dFd3JwRWNsNjByWjhM?= =?utf-8?B?QzVaMFpXNlpIdzFNU2lYenl6TTVjN2M4VTMzOG9YTHp0bkNqWlBLQTRBNUxT?= =?utf-8?B?bzdZTkhiS0MwM0RRUW05Ukh1S2dNL09YK1BlU293UHV5NHh0NU5QZXdOVlQv?= =?utf-8?B?em5Va1FVdDV2dU5EMFRFMHZjQ0F5SnpVZ3RLVzF3ZTAvYWxyRlhHOExnRER0?= =?utf-8?B?MVg5OXQyTHd2N25SUVpreVpIZXhVbVN0cTZSdURFaFg1WC9sSkhJdTlPQnEz?= =?utf-8?B?NnpVR2FYVnlDNVFsNTg4NnNWVkpNZTVDL0IrS0RFaHhEOE51WUhTYTc2U1Vn?= =?utf-8?B?bXhveEhyZEM4ZEZoZTFRMkZGbS8wK3dSS0xIWEFTOElrWm0yYVZPTEYvY2lY?= =?utf-8?B?MFhxN1dJeS9vNE5VS0lhNFdscjFzNnEvaWQ5UmJuZ3NBV2lBVCs2U2Q3dXNJ?= =?utf-8?B?OWhiWHZ5R3pabjRBbzRabEVScFI2azJnSmpKZllLUEduQ3JjQVM0YzhnSzBa?= =?utf-8?B?S3Y1dERvV2d5YngzWTVoK0lCTFArYTZvNVMzZ01uQ0NEaExUekVON2laWDhx?= =?utf-8?B?WEgwek1mU0pnUFVnN3E4NmE3VlhUODh6dkpxdGxZUjA1VDJsRTB5NFFrbUNF?= =?utf-8?B?bkpnL2dVQ0dwZG9QT0hIWGZKcTFqYTFtRWtaWUxuNnhLTG1LVDFBaEhWTnc0?= =?utf-8?B?MTZ6RnE1dzJoaFd1dm8xUmROWkFDckV6Si9xRExhWjZ4cE1HVTljcXVDUVM1?= =?utf-8?B?bEpGRllDSkNnVVRQVC9uT3FPRFZUNHIwYzcvUjZIMWRnZjRUVmhlNHNEaWNX?= =?utf-8?B?RHF6K3c4blBjeDhaeU9iaE5ySlZTTTlVQXhNZEFMRXFNLzN1K0s3cC9lZUk0?= =?utf-8?B?aDJQRVpSc1d3M0hPQlN4b21LUzlGYjlyWlpCWmQ5TFd3R1NVZXVzTzRWWHUz?= =?utf-8?B?a3VDWldNU3BmS1JFOWNSNTZ5WWM0NUE3a3NkSW1YMENLNVJHM1BlZUZ4ck5k?= =?utf-8?B?d0tGTkM3b2g1R3doR3cwL0lEMmZEb0pxc1ZXcW4yc2VPZWNkWkllY3I1V3NP?= =?utf-8?B?SW9lUDJwbnVEYjVXWGJxMXdDOGJjb3BVRkdNQkpBb3c4Mi9ZVFZVQjdtYzZC?= =?utf-8?B?UXNpUUozWHhzVXhwZTJyL3BXNWpua2hwRmdIdXNuZUZDenBnWnVUb3M4WENQ?= =?utf-8?B?b3pnTm81MndtbGRJRWRNMjNwWE9mbVFSMnd3ekpyd0Y5R1VWaTVzNHozOXdv?= =?utf-8?B?bEo0emtEYTArbno3R2JzZGJFT0RUa0w5aEJiNjVEYVg4QWU3MVBtNjNwdGhU?= =?utf-8?B?TFI0UkFNZm5UY3N5MlhXYThKTjVmQTdkNnBGSkhab1Y1MENDR051UzdkaTBl?= =?utf-8?B?bkV6MUNTSkV0Z1UvZVhJNjN2eTJZNkROMUNGWG1wTEVkMmF1c004SVkzdHo4?= =?utf-8?B?NjM1RGcvUmFxdHFBYUFRbW1tWlZTdHNhbGl1VXhoR1E1U1owL0tsVHZBSlZz?= =?utf-8?B?RG9ocHNWZ3ZjTktFS2lPNFRMK251R1JRSjdlR2JQV1RuMzBxVWtRK0FUSTNW?= =?utf-8?B?RzM1UTNNMDNaOU9KVUhlbytaSDQ1cFpEYkdKMGk2eW1XY2lYZ2crY3I4aFNx?= =?utf-8?B?NytGdDF6b3hhZjNmcVNlWnJSN1dpV0pTdFVrTkhhY28zM1ZEajNpUDlLOGhx?= =?utf-8?B?SC9qeVJ6L3RVQkozZW1sMUdSaG1ES0dwdS9HYXFwK0lUV01lTk5sVU5vNVp6?= =?utf-8?B?Sk5kdXg4N1MrMWdKRFVMV1NPK0dlUVRselBPTm4yWjhNcEJKQXBwTlhRUFd4?= =?utf-8?B?d1dUNitHclczcmRRSFM5VEsxYWNZOENFbGF4ekNjbzVndHBmVmlyOTR2eTRX?= =?utf-8?B?YVE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04c883be-7bbd-4eb0-c742-08dbb7f1939f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 02:47:19.6503 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ltl1tHSMfE5Hvxv/w8aUIB2yk58aO0j1rDo9vC5ixePrO59P5VlOp2PBXEn5bE610E/i3mBlz3Tw9rpyv5kvMdKFQ3dgHJBjZNNbT6mGxTo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6435 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Remove the unneeded logic. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/nfpcore/nfp_cpp.h | 107 ---- drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 12 - drivers/net/nfp/nfpcore/nfp_cppcore.c | 162 ------ drivers/net/nfp/nfpcore/nfp_mutex.c | 48 -- drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 24 - drivers/net/nfp/nfpcore/nfp_target.h | 567 --------------------- 6 files changed, 920 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp_cpp.h b/drivers/net/nfp/nfpcore/nfp_cpp.h index 782272a3f4..139752f85a 100644 --- a/drivers/net/nfp/nfpcore/nfp_cpp.h +++ b/drivers/net/nfp/nfpcore/nfp_cpp.h @@ -96,7 +96,6 @@ struct nfp_cpp_operations { void *(*area_iomem)(struct nfp_cpp_area *area); - void *(*area_mapped)(struct nfp_cpp_area *area); /* * Perform a read from a NFP CPP area * Serialized @@ -457,16 +456,6 @@ void nfp_cpp_area_release_free(struct nfp_cpp_area *area); uint8_t *nfp_cpp_map_area(struct nfp_cpp *cpp, uint32_t cpp_id, uint64_t addr, uint32_t size, struct nfp_cpp_area **area); -/* - * Return an IO pointer to the beginning of the NFP CPP area handle. The area - * must be acquired with 'nfp_cpp_area_acquire()' before calling this operation. - * - * @param[in] area NFP CPP area handle - * - * @return Pointer to IO memory, or NULL on failure. - */ -void *nfp_cpp_area_mapped(struct nfp_cpp_area *area); - /* * Read from a NFP CPP area handle into a buffer. The area must be acquired with * 'nfp_cpp_area_acquire()' before calling this operation. @@ -508,18 +497,6 @@ int nfp_cpp_area_write(struct nfp_cpp_area *area, uint32_t offset, */ void *nfp_cpp_area_iomem(struct nfp_cpp_area *area); -/* - * Verify that IO can be performed on an offset in an area - * - * @param[in] area NFP CPP area handle - * @param[in] offset Offset into the area - * @param[in] size Size of region to validate - * - * @return 0 on success, negative value on failure. - */ -int nfp_cpp_area_check_range(struct nfp_cpp_area *area, - unsigned long long offset, unsigned long size); - /* * Get the NFP CPP handle that is the parent of a NFP CPP area handle * @@ -564,20 +541,6 @@ int nfp_cpp_read(struct nfp_cpp *cpp, uint32_t cpp_id, int nfp_cpp_write(struct nfp_cpp *cpp, uint32_t cpp_id, uint64_t address, const void *kernel_vaddr, size_t length); - -/* - * Fill a NFP CPP area handle and offset with a value - * - * @param[in] area NFP CPP area handle - * @param[in] offset Offset into the NFP CPP ID address space - * @param[in] value 32-bit value to fill area with - * @param[in] length Size of the area to reserve - * - * @return bytes written on success, negative value on failure. - */ -int nfp_cpp_area_fill(struct nfp_cpp_area *area, unsigned long offset, - uint32_t value, size_t length); - /* * Read a single 32-bit value from a NFP CPP area handle * @@ -668,33 +631,6 @@ int nfp_xpb_writel(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t value); */ int nfp_xpb_readl(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t *value); -/* - * Modify bits of a 32-bit value from the XPB bus - * - * @param cpp NFP CPP device handle - * @param xpb_tgt XPB target and address - * @param mask mask of bits to alter - * @param value value to modify - * - * @return 0 on success, or -1 on failure. - */ -int nfp_xpb_writelm(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t mask, - uint32_t value); - -/* - * Modify bits of a 32-bit value from the XPB bus - * - * @param cpp NFP CPP device handle - * @param xpb_tgt XPB target and address - * @param mask mask of bits to alter - * @param value value to monitor for - * @param timeout_us maximum number of us to wait (-1 for forever) - * - * @return >= 0 on success, negative value on failure. - */ -int nfp_xpb_waitlm(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t mask, - uint32_t value, int timeout_us); - /* * Read a 32-bit word from a NFP CPP ID * @@ -789,49 +725,6 @@ int nfp_cpp_mutex_init(struct nfp_cpp *cpp, int target, struct nfp_cpp_mutex *nfp_cpp_mutex_alloc(struct nfp_cpp *cpp, int target, uint64_t address, uint32_t key_id); -/* - * Get the NFP CPP handle the mutex was created with - * - * @param mutex NFP mutex handle - * @return NFP CPP handle - */ -struct nfp_cpp *nfp_cpp_mutex_cpp(struct nfp_cpp_mutex *mutex); - -/* - * Get the mutex key - * - * @param mutex NFP mutex handle - * @return Mutex key - */ -uint32_t nfp_cpp_mutex_key(struct nfp_cpp_mutex *mutex); - -/* - * Get the mutex owner - * - * @param mutex NFP mutex handle - * @return Interface ID of the mutex owner - * - * NOTE: This is for debug purposes ONLY - the owner may change at any time, - * unless it has been locked by this NFP CPP handle. - */ -uint16_t nfp_cpp_mutex_owner(struct nfp_cpp_mutex *mutex); - -/* - * Get the mutex target - * - * @param mutex NFP mutex handle - * @return Mutex CPP target (ie NFP_CPP_TARGET_MU) - */ -int nfp_cpp_mutex_target(struct nfp_cpp_mutex *mutex); - -/* - * Get the mutex address - * - * @param mutex NFP mutex handle - * @return Mutex CPP address - */ -uint64_t nfp_cpp_mutex_address(struct nfp_cpp_mutex *mutex); - /* * Free a mutex handle - does not alter the lock state * diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c index 881f21bfd0..ec14ec45dc 100644 --- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c @@ -471,17 +471,6 @@ nfp6000_area_acquire(struct nfp_cpp_area *area) return 0; } -static void * -nfp6000_area_mapped(struct nfp_cpp_area *area) -{ - struct nfp6000_area_priv *area_priv = nfp_cpp_area_priv(area); - - if (area_priv->iomem == NULL) - return NULL; - - return area_priv->iomem; -} - static void nfp6000_area_release(struct nfp_cpp_area *area) { @@ -829,7 +818,6 @@ static const struct nfp_cpp_operations nfp6000_pcie_ops = { .area_init = nfp6000_area_init, .area_acquire = nfp6000_area_acquire, .area_release = nfp6000_area_release, - .area_mapped = nfp6000_area_mapped, .area_read = nfp6000_area_read, .area_write = nfp6000_area_write, .area_iomem = nfp6000_area_iomem, diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c index 627d4eaa5d..7e7c36eda3 100644 --- a/drivers/net/nfp/nfpcore/nfp_cppcore.c +++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c @@ -388,35 +388,6 @@ nfp_cpp_area_write(struct nfp_cpp_area *area, return area->cpp->op->area_write(area, kernel_vaddr, offset, length); } -void * -nfp_cpp_area_mapped(struct nfp_cpp_area *area) -{ - if (area->cpp->op->area_mapped) - return area->cpp->op->area_mapped(area); - return NULL; -} - -/* - * nfp_cpp_area_check_range - check if address range fits in CPP area - * - * @area: CPP area handle - * @offset: offset into CPP area - * @length: size of address range in bytes - * - * Check if address range fits within CPP area. Return 0 if area fits - * or negative value on error. - */ -int -nfp_cpp_area_check_range(struct nfp_cpp_area *area, - unsigned long long offset, - unsigned long length) -{ - if (((offset + length) > area->size)) - return -EFAULT; - - return 0; -} - /* * Return the correct CPP address, and fixup xpb_addr as needed, * based upon NFP model. @@ -671,82 +642,6 @@ nfp_cpp_from_device_name(struct rte_pci_device *dev, return nfp_cpp_alloc(dev, driver_lock_needed); } -/* - * Modify bits of a 32-bit value from the XPB bus - * - * @param cpp NFP CPP device handle - * @param xpb_tgt XPB target and address - * @param mask mask of bits to alter - * @param value value to modify - * - * @return 0 on success, or -1 on failure. - */ -int -nfp_xpb_writelm(struct nfp_cpp *cpp, - uint32_t xpb_tgt, - uint32_t mask, - uint32_t value) -{ - int err; - uint32_t tmp; - - err = nfp_xpb_readl(cpp, xpb_tgt, &tmp); - if (err < 0) - return err; - - tmp &= ~mask; - tmp |= (mask & value); - return nfp_xpb_writel(cpp, xpb_tgt, tmp); -} - -/* - * Modify bits of a 32-bit value from the XPB bus - * - * @param cpp NFP CPP device handle - * @param xpb_tgt XPB target and address - * @param mask mask of bits to alter - * @param value value to monitor for - * @param timeout_us maximum number of us to wait (-1 for forever) - * - * @return >= 0 on success, or negative value on failure. - */ -int -nfp_xpb_waitlm(struct nfp_cpp *cpp, - uint32_t xpb_tgt, - uint32_t mask, - uint32_t value, - int timeout_us) -{ - uint32_t tmp; - int err; - - do { - err = nfp_xpb_readl(cpp, xpb_tgt, &tmp); - if (err < 0) - goto exit; - - if ((tmp & mask) == (value & mask)) { - if (timeout_us < 0) - timeout_us = 0; - break; - } - - if (timeout_us < 0) - continue; - - timeout_us -= 100; - usleep(100); - } while (timeout_us >= 0); - - if (timeout_us < 0) - err = -ETIMEDOUT; - else - err = timeout_us; - -exit: - return err; -} - /* * nfp_cpp_read - read from CPP target * @cpp: CPP handle @@ -805,63 +700,6 @@ nfp_cpp_write(struct nfp_cpp *cpp, return err; } -/* - * nfp_cpp_area_fill - fill a CPP area with a value - * @area: CPP area - * @offset: offset into CPP area - * @value: value to fill with - * @length: length of area to fill - */ -int -nfp_cpp_area_fill(struct nfp_cpp_area *area, - unsigned long offset, - uint32_t value, - size_t length) -{ - int err; - size_t i; - uint64_t value64; - - value = rte_cpu_to_le_32(value); - value64 = ((uint64_t)value << 32) | value; - - if ((offset + length) > area->size) - return -EINVAL; - - if ((area->offset + offset) & 3) - return -EINVAL; - - if (((area->offset + offset) & 7) == 4 && length >= 4) { - err = nfp_cpp_area_write(area, offset, &value, sizeof(value)); - if (err < 0) - return err; - if (err != sizeof(value)) - return -ENOSPC; - offset += sizeof(value); - length -= sizeof(value); - } - - for (i = 0; (i + sizeof(value)) < length; i += sizeof(value64)) { - err = nfp_cpp_area_write(area, offset + i, &value64, - sizeof(value64)); - if (err < 0) - return err; - if (err != sizeof(value64)) - return -ENOSPC; - } - - if ((i + sizeof(value)) <= length) { - err = nfp_cpp_area_write(area, offset + i, &value, sizeof(value)); - if (err < 0) - return err; - if (err != sizeof(value)) - return -ENOSPC; - i += sizeof(value); - } - - return (int)i; -} - /* * NOTE: This code should not use nfp_xpb_* functions, * as those are model-specific diff --git a/drivers/net/nfp/nfpcore/nfp_mutex.c b/drivers/net/nfp/nfpcore/nfp_mutex.c index 7ac06e897a..edc8137304 100644 --- a/drivers/net/nfp/nfpcore/nfp_mutex.c +++ b/drivers/net/nfp/nfpcore/nfp_mutex.c @@ -178,54 +178,6 @@ nfp_cpp_mutex_alloc(struct nfp_cpp *cpp, return mutex; } -struct nfp_cpp * -nfp_cpp_mutex_cpp(struct nfp_cpp_mutex *mutex) -{ - return mutex->cpp; -} - -uint32_t -nfp_cpp_mutex_key(struct nfp_cpp_mutex *mutex) -{ - return mutex->key; -} - -uint16_t -nfp_cpp_mutex_owner(struct nfp_cpp_mutex *mutex) -{ - uint32_t mur = NFP_CPP_ID(mutex->target, 3, 0); /* atomic_read */ - uint32_t value, key; - int err; - - err = nfp_cpp_readl(mutex->cpp, mur, mutex->address, &value); - if (err < 0) - return err; - - err = nfp_cpp_readl(mutex->cpp, mur, mutex->address + 4, &key); - if (err < 0) - return err; - - if (key != mutex->key) - return -EPERM; - - if (MUTEX_IS_LOCKED(value) == 0) - return 0; - - return MUTEX_INTERFACE(value); -} - -int -nfp_cpp_mutex_target(struct nfp_cpp_mutex *mutex) -{ - return mutex->target; -} - -uint64_t -nfp_cpp_mutex_address(struct nfp_cpp_mutex *mutex) -{ - return mutex->address; -} - /* * Free a mutex handle - does not alter the lock state * diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c index 5492840aa1..bc155b44d8 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c @@ -11,30 +11,6 @@ #include "nfp_nsp.h" #include "nfp6000/nfp6000.h" -#define GENMASK_ULL(h, l) \ - (((~0ULL) - (1ULL << (l)) + 1) & \ - (~0ULL >> (64 - 1 - (h)))) - -#define __bf_shf(x) (__builtin_ffsll(x) - 1) - -#define FIELD_GET(_mask, _reg) \ - (__extension__ ({ \ - typeof(_mask) _x = (_mask); \ - (typeof(_x))(((_reg) & (_x)) >> __bf_shf(_x)); \ - })) - -#define FIELD_FIT(_mask, _val) \ - (__extension__ ({ \ - typeof(_mask) _x = (_mask); \ - !((((typeof(_x))_val) << __bf_shf(_x)) & ~(_x)); \ - })) - -#define FIELD_PREP(_mask, _val) \ - (__extension__ ({ \ - typeof(_mask) _x = (_mask); \ - ((typeof(_x))(_val) << __bf_shf(_x)) & (_x); \ - })) - #define NSP_ETH_NBI_PORT_COUNT 24 #define NSP_ETH_MAX_COUNT (2 * NSP_ETH_NBI_PORT_COUNT) #define NSP_ETH_TABLE_SIZE (NSP_ETH_MAX_COUNT * \ diff --git a/drivers/net/nfp/nfpcore/nfp_target.h b/drivers/net/nfp/nfpcore/nfp_target.h index 03908a894f..195e599d31 100644 --- a/drivers/net/nfp/nfpcore/nfp_target.h +++ b/drivers/net/nfp/nfpcore/nfp_target.h @@ -6,571 +6,4 @@ #ifndef NFP_TARGET_H #define NFP_TARGET_H -#include "nfp_cpp.h" - -#define P32 1 -#define P64 2 - -#define PUSHPULL(_pull, _push) (((_pull) << 4) | ((_push) << 0)) - -#ifndef NFP_ERRNO -#include -#define NFP_ERRNO(x) (errno = (x), -1) -#endif - -static inline int -pushpull_width(int pp) -{ - pp &= 0xf; - - if (pp == 0) - return NFP_ERRNO(EINVAL); - return (2 << pp); -} - -#define PUSH_WIDTH(_pushpull) pushpull_width((_pushpull) >> 0) -#define PULL_WIDTH(_pushpull) pushpull_width((_pushpull) >> 4) - -static inline int -target_rw(uint32_t cpp_id, int pp, int start, int len) -{ - uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - - if (island && (island < start || island > (start + len))) - return NFP_ERRNO(EINVAL); - - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 0, 0): - return PUSHPULL(0, pp); - case NFP_CPP_ID(0, 1, 0): - return PUSHPULL(pp, 0); - case NFP_CPP_ID(0, NFP_CPP_ACTION_RW, 0): - return PUSHPULL(pp, pp); - default: - return NFP_ERRNO(EINVAL); - } -} - -static inline int -nfp6000_nbi_dma(uint32_t cpp_id) -{ - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 0, 0): /* ReadNbiDma */ - return PUSHPULL(0, P64); - case NFP_CPP_ID(0, 1, 0): /* WriteNbiDma */ - return PUSHPULL(P64, 0); - case NFP_CPP_ID(0, NFP_CPP_ACTION_RW, 0): - return PUSHPULL(P64, P64); - default: - return NFP_ERRNO(EINVAL); - } -} - -static inline int -nfp6000_nbi_stats(uint32_t cpp_id) -{ - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 0, 0): /* ReadNbiStats */ - return PUSHPULL(0, P64); - case NFP_CPP_ID(0, 1, 0): /* WriteNbiStats */ - return PUSHPULL(P64, 0); - case NFP_CPP_ID(0, NFP_CPP_ACTION_RW, 0): - return PUSHPULL(P64, P64); - default: - return NFP_ERRNO(EINVAL); - } -} - -static inline int -nfp6000_nbi_tm(uint32_t cpp_id) -{ - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 0, 0): /* ReadNbiTM */ - return PUSHPULL(0, P64); - case NFP_CPP_ID(0, 1, 0): /* WriteNbiTM */ - return PUSHPULL(P64, 0); - case NFP_CPP_ID(0, NFP_CPP_ACTION_RW, 0): - return PUSHPULL(P64, P64); - default: - return NFP_ERRNO(EINVAL); - } -} - -static inline int -nfp6000_nbi_ppc(uint32_t cpp_id) -{ - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 0, 0): /* ReadNbiPreclassifier */ - return PUSHPULL(0, P64); - case NFP_CPP_ID(0, 1, 0): /* WriteNbiPreclassifier */ - return PUSHPULL(P64, 0); - case NFP_CPP_ID(0, NFP_CPP_ACTION_RW, 0): - return PUSHPULL(P64, P64); - default: - return NFP_ERRNO(EINVAL); - } -} - -static inline int -nfp6000_nbi(uint32_t cpp_id, uint64_t address) -{ - uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - uint64_t rel_addr = address & 0x3fFFFF; - - if (island && (island < 8 || island > 9)) - return NFP_ERRNO(EINVAL); - - if (rel_addr < (1 << 20)) - return nfp6000_nbi_dma(cpp_id); - if (rel_addr < (2 << 20)) - return nfp6000_nbi_stats(cpp_id); - if (rel_addr < (3 << 20)) - return nfp6000_nbi_tm(cpp_id); - return nfp6000_nbi_ppc(cpp_id); -} - -/* - * This structure ONLY includes items that can be done with a read or write of - * 32-bit or 64-bit words. All others are not listed. - */ -static inline int -nfp6000_mu_common(uint32_t cpp_id) -{ - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, NFP_CPP_ACTION_RW, 0): /* read_be/write_be */ - return PUSHPULL(P64, P64); - case NFP_CPP_ID(0, NFP_CPP_ACTION_RW, 1): /* read_le/write_le */ - return PUSHPULL(P64, P64); - case NFP_CPP_ID(0, NFP_CPP_ACTION_RW, 2): /* {read/write}_swap_be */ - return PUSHPULL(P64, P64); - case NFP_CPP_ID(0, NFP_CPP_ACTION_RW, 3): /* {read/write}_swap_le */ - return PUSHPULL(P64, P64); - case NFP_CPP_ID(0, 0, 0): /* read_be */ - return PUSHPULL(0, P64); - case NFP_CPP_ID(0, 0, 1): /* read_le */ - return PUSHPULL(0, P64); - case NFP_CPP_ID(0, 0, 2): /* read_swap_be */ - return PUSHPULL(0, P64); - case NFP_CPP_ID(0, 0, 3): /* read_swap_le */ - return PUSHPULL(0, P64); - case NFP_CPP_ID(0, 1, 0): /* write_be */ - return PUSHPULL(P64, 0); - case NFP_CPP_ID(0, 1, 1): /* write_le */ - return PUSHPULL(P64, 0); - case NFP_CPP_ID(0, 1, 2): /* write_swap_be */ - return PUSHPULL(P64, 0); - case NFP_CPP_ID(0, 1, 3): /* write_swap_le */ - return PUSHPULL(P64, 0); - case NFP_CPP_ID(0, 3, 0): /* atomic_read */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 3, 2): /* mask_compare_write */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 4, 0): /* atomic_write */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 4, 2): /* atomic_write_imm */ - return PUSHPULL(0, 0); - case NFP_CPP_ID(0, 4, 3): /* swap_imm */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 5, 0): /* set */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 5, 3): /* test_set_imm */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 6, 0): /* clr */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 6, 3): /* test_clr_imm */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 7, 0): /* add */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 7, 3): /* test_add_imm */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 8, 0): /* addsat */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 8, 3): /* test_subsat_imm */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 9, 0): /* sub */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 9, 3): /* test_sub_imm */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 10, 0): /* subsat */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 10, 3): /* test_subsat_imm */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 13, 0): /* microq128_get */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 13, 1): /* microq128_pop */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 13, 2): /* microq128_put */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 15, 0): /* xor */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 15, 3): /* test_xor_imm */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 28, 0): /* read32_be */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 28, 1): /* read32_le */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 28, 2): /* read32_swap_be */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 28, 3): /* read32_swap_le */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 31, 0): /* write32_be */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 31, 1): /* write32_le */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 31, 2): /* write32_swap_be */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 31, 3): /* write32_swap_le */ - return PUSHPULL(P32, 0); - default: - return NFP_ERRNO(EINVAL); - } -} - -static inline int -nfp6000_mu_ctm(uint32_t cpp_id) -{ - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 16, 1): /* packet_read_packet_status */ - return PUSHPULL(0, P32); - default: - return nfp6000_mu_common(cpp_id); - } -} - -static inline int -nfp6000_mu_emu(uint32_t cpp_id) -{ - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 18, 0): /* read_queue */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 18, 1): /* read_queue_ring */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 18, 2): /* write_queue */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 18, 3): /* write_queue_ring */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 20, 2): /* journal */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 21, 0): /* get */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 21, 1): /* get_eop */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 21, 2): /* get_freely */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 22, 0): /* pop */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 22, 1): /* pop_eop */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 22, 2): /* pop_freely */ - return PUSHPULL(0, P32); - default: - return nfp6000_mu_common(cpp_id); - } -} - -static inline int -nfp6000_mu_imu(uint32_t cpp_id) -{ - return nfp6000_mu_common(cpp_id); -} - -static inline int -nfp6000_mu(uint32_t cpp_id, uint64_t address) -{ - int pp; - uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - - if (island == 0) { - if (address < 0x2000000000ULL) - pp = nfp6000_mu_ctm(cpp_id); - else if (address < 0x8000000000ULL) - pp = nfp6000_mu_emu(cpp_id); - else if (address < 0x9800000000ULL) - pp = nfp6000_mu_ctm(cpp_id); - else if (address < 0x9C00000000ULL) - pp = nfp6000_mu_emu(cpp_id); - else if (address < 0xA000000000ULL) - pp = nfp6000_mu_imu(cpp_id); - else - pp = nfp6000_mu_ctm(cpp_id); - } else if (island >= 24 && island <= 27) { - pp = nfp6000_mu_emu(cpp_id); - } else if (island >= 28 && island <= 31) { - pp = nfp6000_mu_imu(cpp_id); - } else if (island == 1 || - (island >= 4 && island <= 7) || - (island >= 12 && island <= 13) || - (island >= 32 && island <= 47) || - (island >= 48 && island <= 51)) { - pp = nfp6000_mu_ctm(cpp_id); - } else { - pp = NFP_ERRNO(EINVAL); - } - - return pp; -} - -static inline int -nfp6000_ila(uint32_t cpp_id) -{ - uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - - if (island && (island < 48 || island > 51)) - return NFP_ERRNO(EINVAL); - - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 0, 1): /* read_check_error */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 2, 0): /* read_int */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 3, 0): /* write_int */ - return PUSHPULL(P32, 0); - default: - return target_rw(cpp_id, P32, 48, 4); - } -} - -static inline int -nfp6000_pci(uint32_t cpp_id) -{ - uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - - if (island && (island < 4 || island > 7)) - return NFP_ERRNO(EINVAL); - - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 2, 0): - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 3, 0): - return PUSHPULL(P32, 0); - default: - return target_rw(cpp_id, P32, 4, 4); - } -} - -static inline int -nfp6000_crypto(uint32_t cpp_id) -{ - uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - - if (island && (island < 12 || island > 15)) - return NFP_ERRNO(EINVAL); - - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 2, 0): - return PUSHPULL(P64, 0); - default: - return target_rw(cpp_id, P64, 12, 4); - } -} - -static inline int -nfp6000_cap_xpb(uint32_t cpp_id) -{ - uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - - if (island > 63) - return NFP_ERRNO(EINVAL); - - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 0, 1): /* RingGet */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 0, 2): /* Interthread Signal */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 1, 1): /* RingPut */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 1, 2): /* CTNNWr */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 2, 0): /* ReflectRd, signal none */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 2, 1): /* ReflectRd, signal self */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 2, 2): /* ReflectRd, signal remote */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 2, 3): /* ReflectRd, signal both */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 3, 0): /* ReflectWr, signal none */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 3, 1): /* ReflectWr, signal self */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 3, 2): /* ReflectWr, signal remote */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 3, 3): /* ReflectWr, signal both */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, NFP_CPP_ACTION_RW, 1): - return PUSHPULL(P32, P32); - default: - return target_rw(cpp_id, P32, 1, 63); - } -} - -static inline int -nfp6000_cls(uint32_t cpp_id) -{ - uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - - if (island > 63) - return NFP_ERRNO(EINVAL); - - switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { - case NFP_CPP_ID(0, 0, 3): /* xor */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 2, 0): /* set */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 2, 1): /* clr */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 4, 0): /* add */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 4, 1): /* add64 */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 6, 0): /* sub */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 6, 1): /* sub64 */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 6, 2): /* subsat */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 8, 2): /* hash_mask */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 8, 3): /* hash_clear */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 9, 0): /* ring_get */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 9, 1): /* ring_pop */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 9, 2): /* ring_get_freely */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 9, 3): /* ring_pop_freely */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 10, 0): /* ring_put */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 10, 2): /* ring_journal */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 14, 0): /* reflect_write_sig_local */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 15, 1): /* reflect_read_sig_local */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 17, 2): /* statistic */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 24, 0): /* ring_read */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 24, 1): /* ring_write */ - return PUSHPULL(P32, 0); - case NFP_CPP_ID(0, 25, 0): /* ring_workq_add_thread */ - return PUSHPULL(0, P32); - case NFP_CPP_ID(0, 25, 1): /* ring_workq_add_work */ - return PUSHPULL(P32, 0); - default: - return target_rw(cpp_id, P32, 0, 64); - } -} - -static inline int -nfp6000_target_pushpull(uint32_t cpp_id, uint64_t address) -{ - switch (NFP_CPP_ID_TARGET_of(cpp_id)) { - case NFP6000_CPPTGT_NBI: - return nfp6000_nbi(cpp_id, address); - case NFP6000_CPPTGT_VQDR: - return target_rw(cpp_id, P32, 24, 4); - case NFP6000_CPPTGT_ILA: - return nfp6000_ila(cpp_id); - case NFP6000_CPPTGT_MU: - return nfp6000_mu(cpp_id, address); - case NFP6000_CPPTGT_PCIE: - return nfp6000_pci(cpp_id); - case NFP6000_CPPTGT_ARM: - if (address < 0x10000) - return target_rw(cpp_id, P64, 1, 1); - else - return target_rw(cpp_id, P32, 1, 1); - case NFP6000_CPPTGT_CRYPTO: - return nfp6000_crypto(cpp_id); - case NFP6000_CPPTGT_CTXPB: - return nfp6000_cap_xpb(cpp_id); - case NFP6000_CPPTGT_CLS: - return nfp6000_cls(cpp_id); - case 0: - return target_rw(cpp_id, P32, 4, 4); - default: - return NFP_ERRNO(EINVAL); - } -} - -static inline int -nfp_target_pushpull_width(int pp, int write_not_read) -{ - if (pp < 0) - return pp; - - if (write_not_read) - return PULL_WIDTH(pp); - else - return PUSH_WIDTH(pp); -} - -static inline int -nfp6000_target_action_width(uint32_t cpp_id, uint64_t address, - int write_not_read) -{ - int pp; - - pp = nfp6000_target_pushpull(cpp_id, address); - - return nfp_target_pushpull_width(pp, write_not_read); -} - -static inline int -nfp_target_action_width(uint32_t model, uint32_t cpp_id, uint64_t address, - int write_not_read) -{ - if (NFP_CPP_MODEL_IS_6000(model)) { - return nfp6000_target_action_width(cpp_id, address, - write_not_read); - } else { - return NFP_ERRNO(EINVAL); - } -} - -static inline int -nfp_target_cpp(uint32_t cpp_island_id, uint64_t cpp_island_address, - uint32_t *cpp_target_id, uint64_t *cpp_target_address, - const uint32_t *imb_table) -{ - int err; - uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_island_id); - uint8_t target = NFP_CPP_ID_TARGET_of(cpp_island_id); - uint32_t imb; - - if (target >= 16) - return NFP_ERRNO(EINVAL); - - if (island == 0) { - /* Already translated */ - *cpp_target_id = cpp_island_id; - *cpp_target_address = cpp_island_address; - return 0; - } - - if (imb_table == NULL) { - /* CPP + Island only allowed on systems with IMB tables */ - return NFP_ERRNO(EINVAL); - } - - imb = imb_table[target]; - - *cpp_target_address = cpp_island_address; - err = _nfp6000_cppat_addr_encode(cpp_target_address, island, target, - ((imb >> 13) & 7), - ((imb >> 12) & 1), - ((imb >> 6) & 0x3f), - ((imb >> 0) & 0x3f)); - if (err == 0) { - *cpp_target_id = - NFP_CPP_ID(target, NFP_CPP_ID_ACTION_of(cpp_island_id), - NFP_CPP_ID_TOKEN_of(cpp_island_id)); - } - - return err; -} - #endif /* NFP_TARGET_H */ -- 2.39.1